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

Whats not working with this script? Nothing is coming out on the output.

Asked by 8 years ago
local human = game.Players.LocalPlayer.Character.Humanoid
local hold = human:LoadAnimation(script.Parent.hold)
local tool = script.Parent

tool.Equipped:connect(function()
    hold:Play()
end)
tool.Unequipped:connect(function()
    hold:Stop()
end)

This is all located in a localscript. When I Play solo, the animation does not play.

0
I think it is because animations have to be in the workspace. Just try that and modify your code to fit the location change and try it. rollercoaster57 65 — 8y
0
I have another animation that's working fine in the tool.. HungryJaffer 1246 — 8y

2 answers

Log in to vote
0
Answered by
LevelKap 114
8 years ago

The game probably hasn't loaded the humanoid yet. This works with local scripts, try:

repeat wait() until game.Players.LocalPlayer
human = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

the game will wait until the player has loaded and then also wait for the humanoid to load before proceeding.

Ad
Log in to vote
1
Answered by 8 years ago

Well Jaffer, since no one wants to answer your question, I'll answer it for you. The thing with finding locating the humanoid through localplayer is that the character loads some time after the localplayer. So, this can simply be fixed by adding a wait() of one or 2 seconds at the beginning.

0
Wow Jaffer! Thanks! This actually worked! HungryJaffer 1246 — 8y
0
HAHAHA LevelKap 114 — 8y
0
LOL Filipalla 504 — 7y

Answer this question