Solved Choosing a random Player and executing command as him

  • 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.

LukynkaCZE

Member
May 12, 2019
26
2
3
29
lukynka.ga
Hi, I need to do a command that would pick a random player from world and then execute command as him.

my code:

command /swk:shrink:test <world>:
trigger:
loop all players:
if loop-player's world is "%arg 1%":
add loop-player to {_random::%arg 1%}
set {_player.%arg 1%} to random element out of {_random::*}
run {_player.%arg 1%} command "shrink 10 2" as op

Reload successfull but not working in game.

Pleas help.
Best Regards

(sorry for my english)
 
Hi, I need to do a command that would pick a random player from world and then execute command as him.

my code:

command /swk:shrink:test <world>:
trigger:
loop all players:
if loop-player's world is "%arg 1%":
add loop-player to {_random::%arg 1%}
set {_player.%arg 1%} to random element out of {_random::*}
run {_player.%arg 1%} command "shrink 10 2" as op

Reload successfull but not working in game.

Pleas help.
Best Regards

(sorry for my english)
Debug the variables
 
First of all your issue is this
Code:
add loop-player to {_random::%arg 1%}
You cant add a player to a non open list variable

Second, you can simplify your entire code to this
code_language.skript:
command /swk:shring:test <world>:
    trigger:
        set {_p} to random element of all players in arg-1
        run {_p} command "shrink 10 2" as op
 
Status
Not open for further replies.