Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

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!

0
"Otherwise you should do LoadAnimation on the humanoid", How so? animation:LoadAnimation() ???? I don't know what you're saying. Krektonix_Youtube 85 — 2y
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 Psudar 882 — 2y
0
Done Xapelize 2658 — 2y
0
bad grammar because my english isnt my first langauge Xapelize 2658 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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

Answer this question