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
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.
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.
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.
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.