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 4 years ago
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = game.Players.LocalPlayer.Character or player.CharacterAdded:Wait()
local animation
local anim = script.Parent:WaitForChild("Animation"):Clone()
tool.Equipped:Connect(function()
    animation =character:WaitForChild("Humanoid"):LoadAnimation(anime)
    character = character or tool.Parent or player.Character or player.CharacterAdded:Wait()

     if not animation then
        animation = character.Humanoid:LoadAnimation(animation)
    end
end)
script.Parent.Unequipped:Connect(function()
    animation:Stop()
end)

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 4 years ago
Edited 4 years ago

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

typo :)

edit:

local tool = script.Parent
local player = game.Players.LocalPlayer
local character = game.Players.LocalPlayer.Character or player.CharacterAdded:Wait()
local anim = script.Parent:WaitForChild("Animation") --No need to clone it
tool.Equipped:Connect(function()
    animation = character:WaitForChild("Humanoid"):LoadAnimation(anim)
    if not animation then
        animation = character.Humanoid:LoadAnimation(animation)
    end
    animation:Play()
end)
script.Parent.Unequipped:Connect(function()
    animation:Stop()
end)


0
I have tried it before, it did not change anything. LightningLIon58 49 — 4y
0
'anime' is more than likely your problem here, since you didn't define it? Utter_Incompetence 856 — 4y
0
Changed that, still does not work LightningLIon58 49 — 4y
0
I fixed it myself, thanks for answering :D LightningLIon58 49 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
local animation
script.Parent.Equipped:Connect(function()
    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
    animation:Play()
end)

script.Parent.Unequipped:Connect(function()
        animation:Stop()
end)
--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 4 years ago

I had this problem too...

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

Answer this question