Function nearestEntity

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

LordMefloun

Member
Jul 11, 2020
1
0
0
19
Hi, i have this problem, i tried to do function nearestEntity.
Code:
command /nearest:
    trigger:
        set {_n} to nearestEntity(player)
        broadcast "%{_n}%"
                
function nearestEntity(player: player):
    loop all entities in world of {_player}:
        loop-entity is not {_player}
        set {_dist} to (distance between {_player} and loop-entity *1000) + (random integer between 0 and 999)/1000
        set {_list::%{_dist}%} to loop-entity
    set {_r} the first element of {_list::*}
    return {_r}

When i run '/nearest' nothing happens
upload_2020-7-11_11-34-15.png

Skript is without error
 
Status
Not open for further replies.