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.
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.
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
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
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.
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