So what I’m trying to do here is like the title said; have an animation play when the player is damaged. So far, all of the topics I’ve seen only work when client sided (only you can see the animation, no one else can), but I want to make it so that everyone can see it.
This is my current local script, located in StarterCharacterScripts:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local anim1 = game.ReplicatedStorage.Animation
local anim1 = Humanoid:LoadAnimation(anim1)
local anim2 = game.ReplicatedStorage.Animation2
local anim2 = Humanoid:LoadAnimation(anim2)
local oldHealth = Humanoid.Health
Humanoid.HealthChanged:Connect(function()
if oldHealth > Humanoid.Health then
print("Humanoid took " .. oldHealth - Humanoid.Health .. " damage")
local value = math.random(1,6)
if value == 1 then
anim1.Priority = Enum.AnimationPriority.Action
anim1:Play()
elseif value == 2 then
anim2.Priority = Enum.AnimationPriority.Action
anim2:Play()
end
end
oldHealth = Humanoid.Health
end)
Thanks in advance,
kitekite