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 Choosing a random Player and executing command as him

Discussion in 'Skript' started by LukynkaCZE, Jun 27, 2019.

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

    LukynkaCZE Member

    Joined:
    May 12, 2019
    Messages:
    26
    Likes Received:
    2
    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)

     
  2. Best Answer:
    Post #3 by ShaneBee, Jun 27, 2019
  3. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
    Debug the variables
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    227
    First of all your issue is this
    Code (Text):
    1. 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 (Skript):
    1. command /swk:shring:test <world>:
    2.     trigger:
    3.         set {_p} to random element of all players in arg-1
    4.         run {_p} command "shrink 10 2" as op
     
  5. LukynkaCZE

    LukynkaCZE Member

    Joined:
    May 12, 2019
    Messages:
    26
    Likes Received:
    2
    Thank you all!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...