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.

How can i repeat a loop after if?

Discussion in 'Skript' started by entwickeln, May 22, 2022.

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

    entwickeln Member

    Joined:
    May 11, 2022
    Messages:
    40
    Likes Received:
    0
    loop all players:
    set {_player} to random element of all players
    if player is "Shroush" or "TestPerson21":
    repeat loop <--- how can i make this repeat the thing again when someone is called like this?

    pls help
     
  2. Practice

    Practice Member

    Joined:
    Apr 23, 2022
    Messages:
    37
    Likes Received:
    1
    Do you want to loop again or continue the current loop?
     
  3. entwickeln

    entwickeln Member

    Joined:
    May 11, 2022
    Messages:
    40
    Likes Received:
    0
    i want to loop the first loop again
     
  4. Mich

    Mich Active Member

    Joined:
    Jul 15, 2020
    Messages:
    148
    Likes Received:
    5
    What are you trying to do because it doesn't make any sense. If you tell us we can tell you a way to accomplish what you're trying to do.
    Because it doesn't make any sense to loop all players and then set {_player} to a random element out of players. Because if you are using a command to find a random player or a event you can just set {_player} to a random element out of players whidout the need to loop all players. Why do you want to choose a player and then repeat the loop again?
    This is what I think too are trying to do
    Code (Text):
    1. Function FindPlayer():
    2.     Set {_player} to a random element of all players
    3.     If {_player} is "player1" or "player2":
    4.         #code if you find the player
    5.     Else:
    6.         Findplayer()#repeat loop again
    7.         Wait a tick#or the server will probably crash
    8.  
    9.  
    10. Command /randomplayer:
    11.     Trigger:
    12.         FindPlayer()
     
  5. entwickeln

    entwickeln Member

    Joined:
    May 11, 2022
    Messages:
    40
    Likes Received:
    0
    It's the thing i searched BUT i i get an error, it's says that he can't understand "function findplayer():
    Do i need an Addon for this?
    --- Double Post Merged, May 24, 2022, Original Post Date: May 24, 2022 ---
    What do i have to write in the ()?
     
  6. Mich

    Mich Active Member

    Joined:
    Jul 15, 2020
    Messages:
    148
    Likes Received:
    5
    You don't need addons and is not necessary to have values inside () but there is a tutorial about function in this page.
    But you can try adding this (s: string)
    Then when you call the function
    FindPlayer("ASDS")
     
  7. entwickeln

    entwickeln Member

    Joined:
    May 11, 2022
    Messages:
    40
    Likes Received:
    0
    not working, it's says the skript can't understand..
     
Thread Status:
Not open for further replies.

Share This Page

Loading...