Adding a second animation to weapon

Hey Devs :wave:
I am trying to add a second animation to a scythe im making

local Debounce = true
local animation
local player = game.Players.LocalPlayer
script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
       if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
            if Debounce == false then return end
                Debounce = false
                animation = player.Character.Humanoid:LoadAnimation(script.Parent.Attack)
                animation:Play() 
            wait(0.5)
                Debounce = true
            elseif player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
                if Debounce == false then return end
                Debounce = false
                   animation = player.Character.Humanoid:LoadAnimation(script.Parent.AttackR15)
                animation:Play()
            wait(0.5)
                Debounce = true
            end
        end)
    end)


script.Parent.Unequipped:Connect(function()
    if animation then
        animation:Stop()
        animation = nil
    end
end)

This is my script that I have (I’m using both R15 and R6)
Thanks!

1 Like

Are you looking for it to be random, or for it to alternate?
For random, try something like this:

local animationsR16 = {script.Parent.Attack, script.Parent.Attack2}

local chosenAnimation = animationsR6[math.random(1,2)] -- chooses the animation

For alternating try something like this:

local hasClicked = 0

hasClicked = hasClicked + 1
if hasClicked % 2 == 0 then
    --play anim 1
else
    --play anim 2
end
1 Like

Hey 7z99, I tried that and it didn’t work, maybe I put it in the wrong place.

local Debounce = true
local animation
local hasClicked = 0
script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
       if game.Players.LocalPlayer.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
        	if Debounce == false then return end
        		Debounce = false
        		animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Attack)
		        animation:Play() 
		    wait(0.5)
		        Debounce = true
		    elseif game.Players.LocalPlayer.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		        if Debounce == false then return end
		        Debounce = false
			hasClicked = hasClicked + 1
			if hasClicked % 2 == 0 then
				animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.AttackR15)
			else
				animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.AttackR152)
			end
        	wait(0.5)
        		Debounce = true
            end
        end)
    end)


script.Parent.Unequipped:Connect(function()
	if animation then
		animation:Stop()
		animation = nil
	end
end)

P.S
I was testing for only R 15 so scroll down to the R15 part.

It doesn’t look like you are playing the animation.

@7z99
It worked thank you so much :slight_smile:

1 Like