1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Player selector gui?

Discussion in 'Skript' started by dudle, Mar 9, 2018.

Thread Status:
Not open for further replies.
  1. dudle

    dudle Active Member

    Joined:
    Jan 31, 2017
    Messages:
    135
    Likes Received:
    0
    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 (Skript):
    1. on rightclick holding a stick:
    2.     create a gui with id "SELECTGUI" with virtual chest with 4 rows named "Select":
    3.         set {_n} to 0
    4.         set {_player} to number of all players
    5.         loop {_player} times:
    6.             loop all players:
    7.                 make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
    8.                     teleport the player to loop-player
    9.                     message "%loop-player%"
    10.                     close player's inventory
    11.             add 1 to {_n}
    12.     open last gui to player
     
  2. Best Answer:
    Post #2 by Donut, Mar 9, 2018
  3. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    your loop logic is off. that would loop through the players the amount of times that there are players on the server.
    Code (Skript):
    1. on rightclick holding a stick:
    2.     create a gui with virtual chest with 4 rows named "Select": #no need for id since you create a new gui every time
    3.         set {_n} to 0
    4.         loop all players:
    5.             make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
    6.                 teleport the player to loop-player
    7.                 message "%loop-player%"
    8.                 close player's inventory
    9.             add 1 to {_n}
    10.     open last gui to player
     
  4. dudle

    dudle Active Member

    Joined:
    Jan 31, 2017
    Messages:
    135
    Likes Received:
    0
    Thanks! The gui now works fine, but the issue with teleportation still persists.
    Code (Skript):
    1.                 teleport the player to loop-player
    2.                 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?
     
  5. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    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 (Skript):
    1. loop all players:
    2.     set {_targetPlayer} to loop-player
    3.     make gui slot {_n} with loop-player's skull named "&r%loop-player's name%":
    4.          teleport the player to {_targetPlayer}
    5.          message "%{_targetPlayer}%
    6.  
    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
     
  6. dudle

    dudle Active Member

    Joined:
    Jan 31, 2017
    Messages:
    135
    Likes Received:
    0
    Works perfectly now, thanks a ton!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...