Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop equipped animation?

My character won't stop the equipped animation even after I unequip it. Here's the script:

local debounce = false

script.Parent.Equipped:Connect(function(mouse)
	local wield = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)
	wield:Play()
	
		mouse.Button1Down:Connect(function()
			if not debounce then
				debounce = true
				local wield = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)			
				local lunge = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Lunge)
				wield:Stop()
				lunge:Play()
				debounce = false		
			end
		end)
		
		mouse.Button1Up:Connect(function()
			if not debounce then
				debounce = true
				script.Parent.CanDamage.Value = true
				
				local wield = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)					
				local slash = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Slash)
				slash:Play()
				wait(1)
				slash:Stop()
				wield:Play()
				
				script.Parent.Blade.Touched:Connect(function(hit)
					if script.Parent.CanDamage.Value == true then
						script.Parent.CanDamage.Value = false
						hit.Parent.Humanoid:TakeDamage(100)
					end
				end)
				debounce = false			
			end
		end)
end)

2 comments

0

Use the .Uneqipped event.

0

i did but the animation still didnt stop

1 answer

Try this.

-- [ Debounces ] --
local debounce = false
local CanDamage = script.Parent:WaitForChild("CanDamage")

-- [ Animations ] --
local wield = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Wield)
local lunge = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Lunge)
local slash = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Slash)

-- [ Settings ] --
local Damage = 100

-- [ Events ] --
script.Parent.Equipped:Connect(function(mouse)
    wield:Play()

    -- [ Lunge ] --
    mouse.Button1Down:Connect(function()
        if not debounce then
            debounce = true
            wield:Stop()
            lunge:Play()
            debounce = false        
        end
    end)

    -- [ Slash ] --
    mouse.Button1Up:Connect(function()
        if not debounce then
            debounce = true
            CanDamage.Value = true                
            slash:Play()
            wait(1)
            slash:Stop()
            wield:Play()
            -- [ Damage ] --
            script.Parent.Blade.Touched:Connect(function(hit)
                if CanDamage.Value == true then
                    CanDamage.Value = false
                    hit.Parent.Humanoid:TakeDamage(Damage)
                end
            end)
            wait(.1)
            debounce = false            
        end
    end)
end)

script.Parent.Unequipped:Connect(function()
	if wield.IsPlaying == true then
		wield:Stop()
	end	
	if lunge.IsPlaying == true then
		lunge:Stop()
	end	
	if slash.IsPlaying == true then
		slash:Stop()
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.