Ad
Log in to vote
0

NPC animation not playing?

Asked by
Scaii_0 94
5 months ago
Edited 5 months ago

I have a simple animation for an NPC. There's a script in the character with and animation inside. The AnimationID of it are the numbers that come up from the animations tab on the website link.

The script goes like this:


local anim = script:WaitForChild('Animation') local hu = script.Parent:WaitForChild("Humanoid") local dance = hu:LoadAnimation(anim) wait(1) dance:Play()

But for some reason it doesn't do anything. When I put in a print after the Play()

eg:

wait(1)

dance:Play()
print('Played')

It DOES print 'Played' although I can't see it animating.

Is there a different ID I need to use for the animation? I know for gamepasses there is a different Data-Asset-ID, so is there something similar for animations too?

Please help.

4 answers

Log in to vote
0
Answered by
RjsMc 36
5 months ago

Actually it seems about right. Try changing script:WaitForChild("Animation") to script.Animation

Everything seems right.

Here are the things you need to check for:

  • If the NPC is anchored, unanchor it.

  • If you want the NPC to not move, even though you need the NPC unanchored, then anchor the HumanoidRootPart

  • Another way is to add this script:

script.Parent.Parent.HumanoidRootPart.Anchored = true

Hope this helps!

0
Nothing is working... I've even tried using a different animation Scaii_0 94 — 5mo
Ad
Log in to vote
1
Answered by 5 months ago
Edited 5 months ago

The problem is that you're setting something that isn't really a variable (things like do, time, then, cannot be changed)

You can see them easily, it's highlighted in blue (unless you change the colors!)

--> Answer

Change your variable to another one, like animTrack

0
it still doesn't do anything if i change it Scaii_0 94 — 5mo
0
The animation has to be yours, you have to be the one who made the animation because roblox doesnt allow you to use other people animations iamthedeveloper1 9 — 5mo
0
It is mine Scaii_0 94 — 5mo
0
Is there an error like --> Animation ... failed to load in ...? RedcommanderV2 1239 — 5mo
View all comments (5 more)
0
Nope... Scaii_0 94 — 5mo
0
Are you running it froma script or local script and where is it located? RedcommanderV2 1239 — 5mo
0
Script, its in the NPC's character Scaii_0 94 — 5mo
0
Just like I said in the original post Scaii_0 94 — 5mo
0
Are you sure it doesn't play? Try another animation first (a roblox default one should be good for testing) RedcommanderV2 1239 — 5mo
Log in to vote
0
Answered by 5 months ago

Try if this works:

local Animation = Instance.new('Animation')
local AnimTrack = nil 

Animation.AnimationId = "" -- paste your animation id here

AnimTrack = humanoid:LoadAnimation(Animation)
AnimTrack:Play()
Log in to vote
0
Answered by
Scaii_0 94
5 months ago

Turns out that place is just broken because when I tried a different place with the EXACT SAME THINGS it worked. :/

Answer this question