Can someone explain to me why the animations are not loading?

Basically I made an animation for when a person has the sword equipped but I get this error

local tool = script.Parent

local animacion = script.equipAnimation
local animaciongolpeo = script.Animgolpeone
local animaciongolped = script.Animgolpetwo
local contador = 1

local animacionPlay

tool.Equipped:Connect(function()

    local humanoid = script.Parent.Parent.Humanoid
    animacionPlay = humanoid:LoadAnimation(animacion)
    animacionPlay:Play()
    
    local
    
end)

tool.Unequipped:Connect(function()
    animacionPlay:Stop()
end)

tool.Activated:Connect(function()
    local humanoid = script.Parent.Parent.Humanoid
    
    if contador == 1 then
        
        local animaciononee = humanoid:LoadAnimation(animaciongolpeo)
        animaciononee:Play()
        contador = contador + 1
        
        
    elseif contador == 2 then
        local animaciontwoo = humanoid:LoadAnimation(animaciongolped)
        animaciontwoo:Play()
        
        contador = 1
        
    end
end)
3 Likes

Try this:

local tool = script.Parent

local animacion = script.equipAnimation
local animaciongolpeo = script.Animgolpeone
local animaciongolped = script.Animgolpetwo
local contador = 1

local animacionPlay

tool.Equipped:Connect(function()

    local humanoid = script.Parent.Parent.Humanoid
    animacionPlay = humanoid:LoadAnimation(animacion)
    animacionPlay:Play()
    
end)

tool.Unequipped:Connect(function()
    animacionPlay:Stop()
end)

tool.Activated:Connect(function()
    local humanoid = script.Parent.Parent.Humanoid
    
    if contador == 1 then
        
        local animaciononee = humanoid:LoadAnimation(animaciongolpeo)
        animaciononee:Play()
        contador = contador + 1
        
        
    elseif contador == 2 then
        local animaciontwoo = humanoid:LoadAnimation(animaciongolped)
        animaciontwoo:Play()
        
        contador = 1
        
    end
end)
2 Likes

Thank you very much, it worked for me. Can you explain why I got the error so I don’t make it again?

2 Likes

It wasn’t error in loading animation, you just accidentally added local in line 16 without anything.

2 Likes

It’s true jajaja
I did not realize
Also thank you very much for helping me

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.