NPC Animation Not Showing Problem[SOLVED]

The code is running but the animation is not playing. I created the model by going to: Avatar, Rig Builder, R6 and block. Then I deleted the original animation script and made my own


This is the script I’m using. I already put the animation ID: rbxassetid://1083216690
image

wait(3)
local humanoid = script.Parent:WaitForChild("Humanoid")
local runanimation = script:WaitForChild("Animation")
local run = humanoid:LoadAnimation(runanimation)
print("play")
while true do
	run:Play()
	wait()	
end

I followed this tutorial: https://www.youtube.com/watch?v=RvgSX9cuFiM

I don’t think I can change to the Animation Controller because I need the humanoid for moving the NPC.
thanks!

3 Likes

Is the NPC anchored? That might stop the animation from playing

1 Like

not anchored

ฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺ

1 Like

If you want your animation to loop (As i assume you do since its put in a while true loop) you could instead do this to loop it

local humanoid = script.Parent:WaitForChild("Humanoid")
local runanimation = script:WaitForChild("Animation")
local run = humanoid:LoadAnimation(runanimation)

run:Play()
run.Looped = true
1 Like

It’s a new knowledge for me but it still doesn’t work

1 Like

Did you put in the animation ID under the “Animation” portion?

1 Like

yes, but I the script is the parent of animation. I think it doesn’t matter as long as it’s inside the workspace
image

1 Like

image

1 Like

Yea that wont matter, as long as it has an animation ID and is called in the code then it shouldn’t matter.

I assume there is no other code in the script?

yes, there isn’ t any
ฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺฺv

Can you try another animation ID? It might be a problem with the animation itself.

I tried a few of them but it still not running

Are the animations you’re using your own animations? And if they are not, have you gotten permission to use them? That can sometimes stop you from being able to use an animation

oh maybe but I’m using Roblox’s animation right now

I will make my own animation to see if it works or not :+1:

You should have access to Roblox animations, especialy since it came from a roblox tutorial. I just tested their animation on one of my own NPC’s and it worked just fine.

can you copy the code and send it to me plz or it’s the same code?

Its essentialy the same, just the variables are named different, but please try it out, maybe it will work.

local animation = script:WaitForChild("idle")
local humanoid = script.Parent:WaitForChild("Humanoid")
local idle = humanoid:LoadAnimation(animation)
idle:Play()
idle.Looped = true

It’s probably because of an external factor. It’s not working for me.

Maybe replace

humanoid:LoadAnimation(runanimation)

with

humanoid.Animator:LoadAnimation(runanimation)

Wouldn’t do much but humanoid:LoadAnimation() is deprecated I think.