Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Target Nearest Player Instead?

Asked by 8 years ago

Here's my code. I'd like to take this and instead make MyTarget the nearest player instead of a random one. This will ensure the enemy targets a Survivor and not somebody who has already died. I have no idea how to do this.

    local humansFound = {}

    local players = game.Players:children()

    if (#players < 1) then return end

    local i = math.random(1, #players)

    myTarget = players[i].Character

Any help is greatly appreciated! Thanks!

0
0
Where is your script located? ChemicalHex 979 — 8y
0
Inside of the "Enemy" block ShiningWindow 127 — 8y

Answer this question