local attacks = script:GetChildren()
for i,v in pairs(attacks) do
local chosenAttack = math.random(#attacks)
script.Parent.Humanoid:LoadAnimation(chosenAttack):Play()
--[[ this picks only 1 random attack, and plays it once. how do i make it randomly play the animations with a 2 second delay? ]]
end
✓ ANSWER ACCEPTED
I have 3 animations for an npc, how do I make them play randomly and constantly with a 2 sec delay?
1 answer
✓ Accepted answer
Simple fix! wait(x) x = Seconds (must be a real number.*)
- Must be Positive, 0+, can have decimals, can't be a negative
What is wait? wait is a delay function, Whatever goes in () is in seconds.
Examples of wait wait(1) < waiting one second print(waited one second)
local attacks = script:GetChildren()
for i,v in pairs(attacks) do
local chosenAttack = math.random(#attacks)
wait(2)
script.Parent.Humanoid:LoadAnimation(chosenAttack):Play()
end
2 comments
0
So I figured it out just now, and this works as well.
0
Aww okay.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Sorry, the script picks 3 animations, plays them all, but then it won't play any more animations. How do I make it do that?