LoadAnimation problem

I think this is not self-explanatory it dosen’t stop when i unequip
local Path = script.Parent.Idle

script.Parent.Equipped:Connect(function()

local Humanoid = script.Parent.Parent:FindFirstChild(‘Humanoid’)

local Idle = Humanoid:LoadAnimation(Path)

Idle:Play()

end)

script.Parent.Unequipped:Connect(function()

local Humanoid = script.Parent.Parent:FindFirstChild(‘Humanoid’)

local Idle = Humanoid:LoadAnimation(Path)

Idle:Stop()

end)

1 Like

It isn’t self-explanatory, we can’t guess. What is the issue you are having?

So when i unequip it doesn’t stop

Is it saying anything in the console?

Try this

   local Idle= nil

    local Path = script.Parent.Idle

    script.Parent.Equipped:Connect(function()

    local Humanoid = script.Parent.Parent:FindFirstChild(‘Humanoid’)

    Idle = Humanoid:LoadAnimation(Path)

    Idle:Play()

    end)

    script.Parent.Unequipped:Connect(function()

    local Humanoid = script.Parent.Parent:FindFirstChild(‘Humanoid’)

    Idle:Stop()

    Idle = nil

    end)

Ty so much
also can you explain nil thingy?

nil basically means its got no value, so when you set it to nil, it obviously has no value, so when they equip it, it gives that idle a value, and it then carries to the unequip since the local part of it isnt in that specific function, then we set it back to nil just cause

1 Like