Hurt walking and idle animations

So i’m making a fighting game and i just wanted to add some animations to spice it up a little bit but i don’t know how could i go about making this :

I want it so when the players health is less than a certain amount it replaces both idle and walking animations with custom ones (such as hurt animations) .I did an attempt but i didn’t know how to make it play when the player is standing or moving. Any help would be appreciated, And thx in advance!

And i just wanted to add something like sound effect that makes all the other sounds just have this blurred effect.

Use moon animator and search up on how you’d like to have it be, moon animator basicly for me simplify’s the roblox animation plugin, its really use full, i’d suggest using that and just adding an script wich gives you the animation if you get damage and when its above the certain amount of health it stops, idle animations can just be changed via scripts.

Yea but how to script it tho?I’ve already animated it i just need the scripting part!

I’d assume that you’d have a function that detects everytime the player health changes like

Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
end)

then when its below something you play the animation etc

Ok, and srry for not making it clear but how to make the hurt walking one play when he is walking and the idle one when he is standing?

https://developer.roblox.com/en-us/api-reference/class/Humanoid

These should help you within your progress

1 Like

Ok thx ill be sure to check it out!

I already made the hurt animations i just need the script for it to work

When the player is hurt, check if the player’s health is equal to or less than a number. If it is, then swap out the animations. If it’s not, then make sure they are the normal animations. That’s basically all you need to do.

1 Like

Can you put a little bit of code so i can understand more how it works?

local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild('Humanoid')

if Humanoid.Health <=25 then
    Humanoid.WalkSpeed = 8 -- if you want to you can change walkspeed
    Character.Animate.walk.WalkAnim.AnimationID = "rbxassetid://" -- put animation id here
else
print("he has okay health")
end

That should work, not enterily sure tho.

1 Like

OK i’ll test it out and see if it works

I tested it and it does not work and does not show any error

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
local sound = script.HurtSound

if Humanoid.Health <=25 then
sound:Play()
    local anim = Humanoid:LoadAnimation("Animation name")
anim:Play()
elseif Humanoid.Health >25 then
anim:Stop()
sound:Stop()
end
end

Wait why is the animation in the humanoid why isn’t it in the script?

The animation will be played on the character(as far as I know). If you put local anim = script.Animation then the script will play the animation on the script and the script will not work.

But where do i put the anim id then?

Actually, reposting with an edit. I’ve realized I have forgot something.

1 Like
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
local sound = script.HurtSound
local animwait = script.HurtAnimation

if Humanoid.Health <=25 then
sound:Play()
    local anim = Humanoid:LoadAnimation(animwait)
anim:Play()
elseif Humanoid.Health >25 then
anim:Stop()
sound:Stop()
end
end
1 Like

wait but how does the script detect if the player is moving?