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

How do i make a different animation play when a player clicks multiple times?

I made a punch script that plays an animation, but i want to make the animation play differently the next time the player clicks, how can i do that? (btw i want it to play 3 different animations and loops back to the first animation)

local Punch = script:WaitForChild("Punch")
		local animTrack = Humanoid:LoadAnimation(Punch)	
			animTrack:Play(0,2,2.5)

^ this is just a small part of my script

1 answer

✓ Accepted answer

Make a variable, set it to 1, check for it, increase its value and finally reset it.

...example:

local currentAttack = 1

function punch()
	if currentAttack == 1 then
		--play your first animation
		currentAttack = 2
	elseif currentAttack == 2 then
		--play your second animation
		currentAttack = 3
	elseif currentAttack == 3 then
		--play your third animation
		currentAttack = 1
	end
end 

2 comments

0

You should show code examples.

0

please do

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