local hum = script.Parent.Humanoid
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
local anims = (math.random(3))
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
wait(5)
end
if anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
wait(5)
end
I saw something wrong with your script. This will works, probably.
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
anim2.Priority = Enum.AnimationPriority.Action
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
anim.Priority = Enum.AnimationPriority.Action --This will forced this animation to play
local anims = (math.random(1,2)) --You need 2 numbers, first number is min and second number is max
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
wait(5)
elseif anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
wait(5)
end
local hum = script.Parent.Humanoid
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
anim2.Priority = Enum.AnimationPriority.Action
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
anim.Priority = Enum.AnimationPriority.Action --This will forced this animation to play
local anims = (math.random(1,2)) --You need 2 numbers, first number is min and second number is max
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
wait(5)
elseif anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
wait(5)
end
It’s because you don’t have a loop. You might need a loop to make this working
local anims = (math.random(1,2)) --This only choose 1 numbers between 1 and 2 for once
So if you want it to make more than 1 animations
Do
local hum = script.Parent.Humanoid
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
anim2.Priority = Enum.AnimationPriority.Action
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
anim.Priority = Enum.AnimationPriority.Action --This will forced this animation to play
local anims = (math.random(1,2)) --You need 2 numbers, first number is min and second number is max
Working = true --if this become false, the NPC will stop playing animations
while Working == true do
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
wait(5)
elseif anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
wait(5)
end
end
Still not working, npc is playing only 1 animation
local hum = script.Parent.Humanoid
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
anim2.Priority = Enum.AnimationPriority.Action
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
anim.Priority = Enum.AnimationPriority.Action --This will forced this animation to play
local anims = (math.random(1,2)) --You need 2 numbers, first number is min and second number is max
Working = true --if this become false, the NPC will stop playing animations
while Working == true do
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
wait(6)
elseif anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
wait(6)
end
end
local hum = script.Parent.Humanoid
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
anim2.Priority = Enum.AnimationPriority.Action
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
anim.Priority = Enum.AnimationPriority.Action --This will forced this animation to play
Working = true
while Working == true do
local anims = (math.random(1,2)) --You need 2 numbers, first number is min and second number is max
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
wait(6)
elseif anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
wait(6)
end
end
local hum = script.Parent.Humanoid
local anim2 = hum:LoadAnimation(script.Parent.dance1) --animation 1
anim2.Priority = Enum.AnimationPriority.Action
local anim = hum:LoadAnimation(script.Parent.dance2) --animation 2
anim.Priority = Enum.AnimationPriority.Action --This will forced this animation to play
Working = true
while Working == true do
wait(6)
local anims = (math.random(1,2)) --You need 2 numbers, first number is min and second number is max
if anims == 1 then
anim:Play()
anim:AdjustSpeed(2) --speed
elseif anims == 2 then
anim2:Play()
anim2:AdjustSpeed(2) --speed
end
end
local Humanoid = script.Parent.Humanoid
local Anims = {
Humanoid:LoadAnimation(script.Parent.dance1),
Humanoid:LoadAnimation(script.Parent.dance2),
}
while true do
local chosenanim = Anims[math.random(1,#Anims)]
chosenanim.Priority = Enum.AnimationPriority.Action
chosenanim:AdjustSpeed(2)
chosenanim:Play()
task.wait(5)
end
It is randomized, however I did not bother to implement a check to stop anims from playing twice, in theory its possible for the same anim to keep playing forever.
I need to make it work like this: randomized animation starts playing (for example dance1) and after animation stopped, script randomly selects which animation will play now.
--Get the anims
local Humanoid = script.Parent.Humanoid
local Anims = {
Humanoid:LoadAnimation(script.Parent.dance1),
Humanoid:LoadAnimation(script.Parent.dance2),
}
--Configure the anins
for i,v in pairs(Anims) do
v.Priority = Enum.AnimationPriority.Action
v:AdjustSpeed(2)
end
--Play the anims
while true do
local chosenanim = Anims[math.random(1,#Anims)]
chosenanim:Play()
chosenanim.Stopped:Wait()
end
No, i need to make it work like this:
Script chooses random animation,- animation dance1 playing - when animation is stopped - repeat the 1 step again.