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

How to play animations on live players?

Asked by
Faazo 84
6 years ago

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.

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 User#5423 17 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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()
0
Accept the answer if it worked. SwingingMelons -18 — 6y
0
the animation ID is already written in its properties, but i'll see if this works Faazo 84 — 6y
0
Lol I like the answer "you can't pop out your animation with the power of your mind..." mixgingengerina10 223 — 6y
0
It didn't work. The exact same thing happened. The same thing was warned in the output. Thanks for trying though! Faazo 84 — 6y

Answer this question