Animation won't play

For some reason, when I try to play my animation it doesnt play, the ai moves properly but doesn’t play the animation.

function GetTorso(part)
	local chars = game.Workspace:GetChildren()
	local torso = nil
	for _, v in pairs(chars) do
		if v:IsA'Model' and v ~= script.Parent and v.Name == GetPlayerNames() then
			local charRoot = v:FindFirstChild'HumanoidRootPart'
			if (charRoot.Position - part).magnitude < SearchDistance then
				torso = charRoot
			local	animation = zombie.Zombie.Animator:LoadAnimation(script.Parent["Stats/Values"].Animations.Walk)
				
				zombie.Zombie:MoveTo(torso.Position)
				animation:Play()
			end
		end
	end
	return torso
end

1 Like

No errors ? Maybe make animation.Looped = true ?

1 Like

No I didnt get any errors, let me try this thank you

1 Like

image
Isthis correct?

Set it to Action. It should work, it’s basically each one overrides the other. Like Action3 overrides Action2 etc

1 Like

Still wont play it is there anything else I can try?

1 Like

If the experience is in a group, make sure you’re publishing the animation to the group.
Try:

 if animation.IsPlaying then
    print("animation playing")
else
   print("animation isn't playing")
end

Sometimes it plays but the character doesn’t want to show it for some reason.

1 Like

Yeah it shows that its playing but the character isnt showing it, is there anyways to fix this?

1 Like

Try to task.wait some seconds before playing the animation, to make sure that the issue is from loading. It plays before the character loads since scripts runs very fast.

1 Like

Tried this, still nothing anything else you can think of?

1 Like

Strange. Is it a group game or your own game ? It could be that the animation is not published in the right place, I mean saved to roblox ? Maybe also try playing the animation on the character with a fresh script, put task.wait(15) at the top of the script and then play the animation, make sure to make the animation looped.

1 Like

It’s a seperate game but i dont own the game, i tried it out on another npc and it also doesnt work

1 Like

Was it you who saved the animation to roblox ? And did you set the creator/owner of the animation to that group where the game is located in ? This may be an issue since the animation is playing but no showing.

1 Like

It appears that your code is missing an “end” statement for the “if” statement that checks whether the distance between “charRoot” and “part” is less than the “SearchDistance”. This may be causing issues with playing the animation properly. You could try adding an “end” statement after the line that sets the “torso” variable to fix this issue. Additionally, you may want to check whether the “zombie” object has a valid Animator component before calling the “LoadAnimation” method.

1 Like