I made this script so that an NPC will move to different waypoints multiple times. However, it only moves there once. Any ideas why it isn't working?
SCRIPT:
local waypoints = { game.Workspace.WayPoint, game.Workspace.WayPointb, game.Workspace.WayPointc, game.Workspace.WayPointd, game.Workspace.WayPointe, game.Workspace.WayPointf }
local chosenWaypoint = waypoints[math.random(1,#waypoints)]
local humanoid = script.Parent.Humanoid
local pos = chosenWaypoint.Position
while true do
wait(1.5) humanoid:MoveTo(chosenWaypoint.Position) humanoid.MoveToFinished:Wait() wait(1.5) humanoid:MoveTo(chosenWaypoint.Position) humanoid.MoveToFinished:Wait()
end
I think it is because you only chose the random way point once. It is outside of the while loop so therefore, it stays the same. For the duration of the loop, the humanoid will move to the same spot. You can simply put the randomizer code inside of the loop.