I'm making a script that randomly moves an NPC to different points around the map; how would I implement a wait that would wait for the NPC to reach the location until it finds another location and moves there?
Here is the script (placed inside the NPC humanoid):
local humanoid = script.Parent local points = workspace.Points:GetChildren() while wait() do local randompoint = points[math.random(1,#points)] script.Parent:MoveTo(randompoint.Position) end
Well, this is a bit buggy in code- try using PathfindingService- but that's not needed, the answer is to just do humanoid.MoveToFinished:Wait()
so..
while true do local randompoint = points[math.random(1,#points)] script.Parent:MoveTo(randompoint.Position) script.Parent.MoveToFinished:Wait() end