Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.