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

How to play animations on live players?

So I made a throwing animation for my game. I have the scripts and the animation and on an npc, it works perfectly fine. When I shift it over to a player however, it doesn't work. here is my localscript:

character = game.Players.LocalPlayer.Character

game.ReplicatedStorage.Animation:Clone().Parent = character

local animation = character.Humanoid:LoadAnimation(character:WaitForChild("Animation"))

 animation:Play()

in the output it says LoadAnimation requires the Humanoid object (Faazo.Humanoid) to be a descendant of the game object What does this mean? The humanoid isn't a descendant of game? It is though. Please help.

1 comment

0

This means you are trying to load a animation before the humanoid is part of the game ie in the workepace. You can do a small check for when the player humanoid is in the workspace

2 answers

✓ Accepted answer

Try checking if humanoid is a part of the character before playing the animation, I'll give just you the script:

local character = game.Players.LocalPlayer.Character
local humanoid = character:WaitForChild("Humanoid")

game.ReplicatedStorage.Animation:Clone().Parent = character

local animation = humanoid:LoadAnimation(character:WaitForChild("Animation"))

animation:Play()

Hope this helped you with your problem! Please accept my answer if it worked for you.

MajinBluee

There should be a line that says the id of the animation, you can't pop out your animation with the power of your mind... Here is a code to make it more simple:

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=AnimationIdhere"

local animTrack = Humanoid:LoadAnimation(animation)
animTrack:Play()

4 comments

0

Accept the answer if it worked.

0

the animation ID is already written in its properties, but i'll see if this works

0

Lol I like the answer "you can't pop out your animation with the power of your mind..."

0

It didn't work. The exact same thing happened. The same thing was warned in the output. Thanks for trying though!

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