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

LoadAnimation requires the Humanoid Object(Player1.Humanoid) to be a descendant of the game object?

Asked by 5 years ago
01local tool = script.Parent
02local player = game.Players.LocalPlayer
03local character = game.Players.LocalPlayer.Character or player.CharacterAdded:Wait()
04local animation
05local anim = script.Parent:WaitForChild("Animation"):Clone()
06tool.Equipped:Connect(function()
07    animation =character:WaitForChild("Humanoid"):LoadAnimation(anime)
08    character = character or tool.Parent or player.Character or player.CharacterAdded:Wait()
09 
10     if not animation then
11        animation = character.Humanoid:LoadAnimation(animation)
12    end
13end)
14script.Parent.Unequipped:Connect(function()
15    animation:Stop()
16end)

I made a team change script that resets the character, then the animation of the tool is completely broken? how do I fix it?

When I reset this error shows up.

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

animation =character:WaitForChild("Humanoid"):LoadAnimation(anime)

typo :)

edit:

01local tool = script.Parent
02local player = game.Players.LocalPlayer
03local character = game.Players.LocalPlayer.Character or player.CharacterAdded:Wait()
04local anim = script.Parent:WaitForChild("Animation") --No need to clone it
05tool.Equipped:Connect(function()
06    animation = character:WaitForChild("Humanoid"):LoadAnimation(anim)
07    if not animation then
08        animation = character.Humanoid:LoadAnimation(animation)
09    end
10    animation:Play()
11end)
12script.Parent.Unequipped:Connect(function()
13    animation:Stop()
14end)
0
I have tried it before, it did not change anything. LightningLIon58 49 — 5y
0
'anime' is more than likely your problem here, since you didn't define it? Utter_Incompetence 856 — 5y
0
Changed that, still does not work LightningLIon58 49 — 5y
0
I fixed it myself, thanks for answering :D LightningLIon58 49 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
01local animation
02script.Parent.Equipped:Connect(function()
03    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
04    animation:Play()
05end)
06 
07script.Parent.Unequipped:Connect(function()
08        animation:Stop()
09end)
10--Script that does work

I have fixed that. I found another script of animation that I have made a while ago that does work, I don't know what the error is but at least it works now.

Log in to vote
0
Answered by 5 years ago

I had this problem too...

Check if there is any other instance in your game that has your name

Answer this question