I need help to freeze player near me

Discussion in 'Skript' started by rafaadivulgador, Oct 18, 2020.

  1. Hello, I need someone to help me how to make a skript that makes this:

    When you click a player with hand, it'll check all players at radius of 20 blocks of player. After that they won't be able to move anymore.

    My failed code:

    Code (Text):
    right click on player with hand:
        loop all players:
            loop all players where [distance between player and player input is smaller than 20]:
                set {stopedplayer::%loop-player%} to true
                loop {stopedplayer::%loop-player%}:
                    send "You have been stopped." to loop-player
                stop
               
    on movement:
        if {stopedplayer::%player% is true:
            cancel event
     
  2. you did many loops within each other when only one loop is needed
    Code (Text):
    loop all players where [distance between player and player input is smaller than 20]:
    and cancelling the move event is a really bad idea, it'll result in a very buggy animation, you can prevent movement by applying negative jump boost effect so they can't jump, setting their hunger to 3 so they can't sprint and then setting their walking speed to 0
     
  3. But how do I make it to apply the effect for all of them? because if If I do effect it'll apply for only one player
     
  4. save them in a list, then loop them