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.
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!
Did it myself since I've already done everything you said. A simple copy from the ROBLOX Api fixed my game.