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

Why does my NPC stop moving mid-walk to a point?

1 answer

✓ Accepted answer

There is a time limit to MoveTo. If it does not reach its destination point it will fire MoveToFinished with false.

You could use this and run the MoveTo function again.

local humanoid = script.Parent.Parent.Giant.Humanoid
local vecList = {
	-- list of positions vector3
}
local curPoint = 1 -- holds the current walk to point

humanoid:MoveTo(vecList [curPoint]) -- the first point 

humanoid.MoveToFinished:Connect(function(foundEnd)
	if foundEnd then
		curPoint = curPoint  + 1 -- go to next point if found
	end
	if vecList [curPoint] then -- check we have a vector3 to walk to
		humanoid:MoveTo(vecList [curPoint])
	else
		print('end') -- no more points
	end
end)

I hope this helps.

3 comments

0

Yes this helps but the script isn't working? I've changed my vecList to local vecList = { game.Workspace.WalkOne } but it doesn't walk to it, and also I got an error, 'Giant is not a valid member of DataModel' ? how do I fix this. So yeah I want to make this cause I'm making a sort of Tower Battles game xD

0

game.Workspace.WalkOne is an instance not the vector 3. Use the Position which is a vector3

0

Okay thank you so much!! IT WORKS :D

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