Hello, i made a gun with an idle anim, but when i unequip the tool the animation doesn't stops to play, can someone help me with this ?

repeat wait() until game.Players.LocalPlayer
local player = script.Parent.Parent.Parent
local mouse = player:GetMouse()
local Enabled = true

script.Parent.Equipped:connect(function()

  mouse.KeyDown:connect(function(key)
	
		if key == "e" and Enabled == true then
		local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
		idle:Play()
		Enabled = false
		
	elseif key == "e" and Enabled == false then
		local aim = script.Parent.Parent.Humanoid:LoadAnimation(script.Aim)
		aim:Play()
		Enabled = true
		
		end
		
		
	end)

end)

script.Parent.Unequipped:connect(function()
	local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
	local aim = script.Parent.Parent.Humanoid:LoadAnimation(script.Aim)
	
	idle:Stop()
	aim:Stop()
	
end)

1 comment

0

hello ?