Dancing NPC not working

Hello Developers,

I am trying to make a dancing NPC. I have the script and stuff that makes it play. I am wanting to use animations made by Roblox like Cabbage Patch but when I put the IDs in they don’t work… Here is my script. Can’t tell if its a Script Problem or what?

local Humanoid = script.Parent:WaitForChild("Humanoid")
local Animation = Humanoid:LoadAnimation(script:FindFirstChildOfClass("Animation"))

Animation.Looped = true
Animation:Play()

The id in the animation is: rbxassetid://3576747102

Another question I have is how can I make it so players can’t move the npcs?

I’m not too experienced in animations as I’ve started using them just recently, but having an Animator object in between always seems to work for me. You would use Instance.new to create it, parent it to the humanoid, then load the animation to the animator. Then continue as you did in your script. Roblox introduced some changes late last year, so if you are following any tutorial, chances are it’s outdated.

I put a animator parented to the humanoid. Then loaded the animation using the following code, but I seems it still is not working. This is weird because I got my other NPC to do Monkey.



local animator = script.Parent:FindFirstChild("Humanoid"):FindFirstChild("Animator")
local animationobject = script:FindFirstChild("Dance")

local animation = animator:LoadAnimation(animationobject)

animation.Looped = true
animation:Play()

I’m afk right now so can’t inspect the code I used for my working animations, but can you see the output for any errors?

These are the only errors in my console and they seem unrelated.image

Yes that’s unrelated. As I already said, I’m away from my computer so take this with grain of salt. I believe I used Instance.new for the animator, then parented it to the humanoid. Then the same with the animation object, created a new one and set the ID of it. Then did something like

local animTrack=animator:LoadAnimation(animation)

Don’t rely on this, but I can’t really understand the current setup in your case.

Weird I just changed the id and it worked on that one.

Maybe roblox stops you from using Arround town?

Is your NPC an R15 or R6 model? If you go to the Roblox website, to the animation, does it work if you choose R15 or R6?

I fell so dumb was because it was R6

1 Like

Ok, glad to know you got it working!