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

If statement detect animation?

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

✓ Accepted answer

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

2 comments

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.

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. :)

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