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

If statement detect animation?

Asked by 6 years ago

I want to make this if then statement occur if the scripts math.random chooses "animation1"

local anims = {script.Animation1,script.Animation2}
local chooseattack = math.random(2)

        local animation = hum:LoadAnimation(anims[chooseattack]) --this will load a random animation, from the array, into the player

        animation:Play() -- plays it

            if animation == 1 then

1 answer

Log in to vote
0
Answered by 6 years ago

I think I understand what you're saying, but I'm not positive; is this what you mean?

local anims = {
    script.Animation1;
    script.Animation2;
}

local attack = math.random(2);
local animation = hum:LoadAnimation(anims[attack]);
animation:Play();
if(attack == 1)then
    -- the chosen attack was the first in the array anims
    -- that means that the animation chosen was script.Animation1
end
0
well i can obviously see lua isnt your first language. Also what you answered is pretty much the same as mine except worded differently, but ill try it out. taunter165 30 — 6y
0
No, it's not, haha. A couple of changes, particularly in changing (animation == 1) to (attack == 1), but other than that your script was pretty solid. :) KidTech101 376 — 6y
Ad

Answer this question