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

How do i make this Humanoid switch targets once it has reached its first one?

Asked by 4 years ago

i have this script

while true do 
    local target = game.Workspace.Map.Turn1
    script.Parent.Humanoid:MoveTo(target.Position, target)
    wait()
end

and i want it to switch targets once it has reached the first one the first target is Turn1 which is a part then the next target would be End with is another part. but idk how to make it change targets :/ Aditional information - Map is a folder in the workspace - the humanoids walkspeed is 5, but idk if that matters in making it switch targets

1 answer

Log in to vote
1
Answered by 4 years ago

You could try use the "humanoid.MoveToFinished:" method Example:

    local target = game.Workspace.Map.Turn1
    function movenext()
        target = (OBJECT GOES HERE) -- next target would go here and repeat the process
        movement()
    end
    function movement()
        wait(1)
        script.Parent.Humanoid:MoveTo(target.Position, target)
        script.Parent.Humanoid.MoveToFinished(movenext)
    end
movement()

Hopefully this solves your problem, if you need more help DM on discord. Matt.#8009

Ad

Answer this question