Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
rexpex 45
7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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 
0
You should show code examples. OldPalHappy 1477 — 7y
0
please do rexpex 45 — 7y
Ad

Answer this question