Solved Player selector gui?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

dudle

Active Member
Jan 31, 2017
135
0
16
45
So I have this code where I want that when I click on someone's skull, I'll be teleported to them. Using TuSKe. This isn't working fine. This first issue is that it won't teleport me to that player. for the debug method I used message "%loop-player%", and it says "<none>". Also, when a new player joins the server, and there's a total of 2 players online, it sets 2 skulls in the gui of only that player. What I want to do is to have all the currently online players' skulls displayed in this gui, one by one (without any pagination, I don't need that), and clicking on a skull will teleport the player to the player of the skull. Someone that can correct this script, please?
PS the example Tuke provided here doesn't work.
My script:
code_language.skript:
on rightclick holding a stick:
    create a gui with id "SELECTGUI" with virtual chest with 4 rows named "Select":
        set {_n} to 0
        set {_player} to number of all players
        loop {_player} times:
            loop all players:
                make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
                    teleport the player to loop-player
                    message "%loop-player%"
                    close player's inventory
            add 1 to {_n}
    open last gui to player
 
your loop logic is off. that would loop through the players the amount of times that there are players on the server.
code_language.skript:
on rightclick holding a stick:
    create a gui with virtual chest with 4 rows named "Select": #no need for id since you create a new gui every time
        set {_n} to 0
        loop all players:
            make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
                teleport the player to loop-player
                message "%loop-player%"
                close player's inventory
            add 1 to {_n}
    open last gui to player
 
your loop logic is off. that would loop through the players the amount of times that there are players on the server.
code_language.skript:
on rightclick holding a stick:
    create a gui with virtual chest with 4 rows named "Select": #no need for id since you create a new gui every time
        set {_n} to 0
        loop all players:
            make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
                teleport the player to loop-player
                message "%loop-player%"
                close player's inventory
            add 1 to {_n}
    open last gui to player
Thanks! The gui now works fine, but the issue with teleportation still persists.
code_language.skript:
                teleport the player to loop-player
                message "%loop-player%"
the debug message says "<none>". I tried putting loop-value, but this did not work either. I don't really get how it works for the loop-player's skull and their name, but doesn't for teleportation... Could you help me, please?
 
im pretty sure its because the code indented under the "make gui slot..." line is treated as separate from the rest of the event because that code is being called when the slot is clicked. a simple variable should do the trick (i think)
code_language.skript:
loop all players:
    set {_targetPlayer} to loop-player
    make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
         teleport the player to {_targetPlayer}
         message "%{_targetPlayer}%
if that doesnt work you could always just grab the player's name from the item in the slot thats clicked and parse it is a player but you shouldnt need to do that
 
im pretty sure its because the code indented under the "make gui slot..." line is treated as separate from the rest of the event because that code is being called when the slot is clicked. a simple variable should do the trick (i think)
code_language.skript:
loop all players:
    set {_targetPlayer} to loop-player
    make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
         teleport the player to {_targetPlayer}
         message "%{_targetPlayer}%
if that doesnt work you could always just grab the player's name from the item in the slot thats clicked and parse it is a player but you shouldnt need to do that
Works perfectly now, thanks a ton!
 
Status
Not open for further replies.