Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my NPC animation work in Studio but doesn't work when really playing the game?

local animation = script:WaitForChild("Animation")

local humanoid = script.Parent:WaitForChild("Humanoid")

local anim = humanoid:LoadAnimation(animation)

anim:Play()

This works in studio ^ But doesn't work in the game. I've had instances when messing around with the code that the NPC looks like he's about to do an animation but he's just sitting still on the first frame, forever. There's no errors or anything. I really need help as most of my fanbase wants animated workers and I need to get this game released before Christmas.

2 answers

✓ Accepted answer

Consider doing local anim = humanoid.Animator:LoadAnimation(animation) if you are trying to play an animation for a real playing character. Otherwise you should do LoadAnimation on the humanoid (Please fix this if I'm wrong but Humanoid:LoadAnimation() is no longer supported.)

Roblox doesn't allow you to play animations that you didn't upload yourself (or if it's a group game, the animation needs to be uploaded to the group). This could be an issue as well

Happy christmas!

4 comments

0

"Otherwise you should do LoadAnimation on the humanoid", How so? animation:LoadAnimation() ???? I don't know what you're saying.

0

You need to rephrase this question as its too vague. A lot can be wrong here. For example, Roblox doesn't allow you to play animations that you didn't upload yourself (or if it's a group game, the animation needs to be uploaded to the group). This could be an issue as well

0

Done

0

bad grammar because my english isnt my first langauge

Did it myself since I've already done everything you said. A simple copy from the ROBLOX Api fixed my game.

This discussion is preserved as it was. New answers, comments, and votes are closed.