Hello! I am trying to make different animations play through a folder while I take Damage form another player. right now I have a script that plays the one animation but I want to loop different animations when hit if anyone can help me thank you.
Also in the game, its not in startercharacterscripts, each script in startercharacterscripts are located in the character. I would instead recommend putting the animation folder in replicated storage and just leave the script in startercharacterscripts.
try implementing my example script like this:
if LastKnownHealth > Humanoid.Health then
print("Playing")
local value = math.random(1,3) --change the 3 to how many animations there are
if value == 1 then
script.Parent.Parent.ReplicatedStorage.animationFolder.Ani:Play()
end
end
local hum = script.Parent.Humanoid
local currenthealth = hum.Health
hum.HealthChanged:Connect(function(health)
if health>currenthealth then
print("Playing")
local value = math.random(1,3)
if value == 1 then
local anim = hum:LoadAnimation(game.ReplicatedStorage.Animation.ani)
anim.Priority = Enum.AnimationPriority.Action
anim:Play()
end
currenthealth = health
end
end)
does your animation even have an animation id? go to view → properties which opens the properties menu. Then highlight the animation and check its animation id.