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

Animation doesn't play when NPC moves?

for i, v  in pairs (game.Workspace.Folder:GetChildren()) do
	v.Humanoid:MoveTo(game.Workspace.Part.Position)
	print("Started")
end

I don't want the NPC to be smart and go around objects, that's why im using moveto instead of pathfinding.

Do I have to play it on my own?

1 answer

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://0" -- Change this

for i, v in pairs(workspace.Folder:GetChildren()) do
	local animtrack = v.Humanoid:LoadAnimation(animation)
	animtrack.Looped = true
	
	v.Humanoid:MoveTo(workspace.Part.Position)
	animtrack:Play()
	print("Started")

	v.Humanoid.MoveToFinished:wait()
	animtrack:Stop()
	print("Ended")
end

Yes, in general, you will need to make sure the NPC is playing the animation manually.

The animtrack.Looped makes sure that the animation keeps playing once it starts unless stopped.

You yourself / ROBLOX must have created the animation or else it will not work

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