NPC animation doesn't work

Hi! So, I’m having an error when executing the script for the NPC to play the animation ( nothing appears in the output )
Can anyone tell me why this happens?

Script :

local Char = script.Parent

local Anim = Char.Humanoid:LoadAnimation(script.Animation)
Anim.Looped = true
Anim:Play()

If nothing appears in the output, do you own the animation that you are trying to run?

1 Like

Yes the animation is mine, so I don’t understand why I can’t use it

Where is the script? And also, just to make sure, you did set the AnimationId for the animation object right? Also, is this experience under your name or under a group? and is the animation saved to your group or under your account?

Well, the script is inside the npc, the animation is saved in my player and the experience was done by team create. Maybe that’s the problem?

try adding a :WaitForChild(‘Animation’), if it not work you can try debugging the code with prints

Okay, I tried to post the experience by my group and animation by the group, but for some reason it still doesn’t work.

1 Like

I tried that too, still doesn’t work

1 Like

did you try debugging the code? insert a print(‘done’) after the animation:Play(), i dont think thats the problem but that still help on my codes sometimes

also, from what i know you cant use animTrack.Looped = true, you have to do it manually on the animation editor for that work

for some reason the animation is not playing for the player, only for the server and it didn’t print either

1 Like

remove the track.looped = true statement and see if that helps in some way

1 Like

It worked!!! Dude it was really worth it, without you I would never have made this work.

1 Like

no problem my man, good luck in your project

1 Like
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = script:WaitForChild("Animation")
local Track = Humanoid:LoadAnimation(Animation)
repeat task.wait() until Track.Length > 0
Track.Looped = true
Track:Play()

The actual issue was instances having not yet replicated to the client at the time of the script’s execution.

1 Like

Thanks for the help, but I already found the solution!

The “Looped” property wasn’t the issue though.

1 Like

but it did, yes I think the looped property was not replicated to the client at that time.
but when i exported the animation with loop enabled it worked