Solved Getting 1 player from loop-player

  • 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 community!

    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
Hello,

So what I want to do is when it loops all players it would select 1 player by random and do something, but how can I do that?

I tried to do, for example, teleport a random element out of loop-player to {location} but it tped all looped players, so how can I get only 1 player out of the loop to get teleported or whatever I want him to happen?
 
You can only choose a random element out of a defined list like {players::*}
 
Hello,

So what I want to do is when it loops all players it would select 1 player by random and do something, but how can I do that?

I tried to do, for example, teleport a random element out of loop-player to {location} but it tped all looped players, so how can I get only 1 player out of the loop to get teleported or whatever I want him to happen?

You're welcome
code_language.skript:
command /randomplayer:
    trigger:
        loop all players:
            add loop-player to {_players::*}
        set {_size} to size of {_players::*}
        set {_x} to a random integer between 1 and {_size}
        teleport {_players::%{_x}%} to {yourlocation}

Or just
code_language.skript:
command /randomplayer:
    trigger:
        add all players to {_players::*}
        set {_size} to size of {_players::*}
        set {_x} to a random integer between 1 and {_size}
        teleport {_players::%{_x}%} to {yourlocation}
 
Or just
code_language.skript:
teleport a random element out of all players to {your location}
 
  • Like
Reactions: YoshYz
Status
Not open for further replies.