Hurt walking and idle animations


Click this button, it should be there on PC too.

Oh ok now i see ,(i’ve already figured out how to solve my problem but i have another one) so here’s the script so far :

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
local animwait = game.ReplicatedStorage:WaitForChild("HurtAnimation")
local idlewait = game.ReplicatedStorage:WaitForChild("IdleAnimation")

Character.Running:Connect(function(speed)
if speed > 0 then
	if Humanoid.Health <=25 then
		local anim = Humanoid:LoadAnimation(animwait)
		anim:Play()
	elseif Humanoid.Health >25 then
		animwait:Stop()
	else
		animwait:Stop()
		local idle = Humanoid:LoadAnimation(idlewait)
       idle:Play()
	end
end
end)

My error is Running is not a valid member of Workspace.FuriousDev(WichIsMyCharacter’s Name)

Isn’t Running a property of Humanoid?
Try typing Humanoid.Running

Oh yeah i didn’t even notice that thx

Now i have another error that says Stop Is not a valid member of animation(HurtAnimation)

Try loading the animations outside the if part

1 Like

Wait should i have the hurt walking animation looped?

I’m not sure, I guess you can try looping it, if it bugs then do not loop it.

I tried both : so for the looping one (it just loops when i release the walking key) and for the non-looped one (it plays one time then stops ) soo… yeah

Put this in StarterCharacterScripts

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local animate = character:WaitForChild("Animate")

local idleAnimationObject = animate.idle.Animation1
local walkAnimationObject = animate.walk.WalkAnim
local runAnimationObject = animate.run.RunAnim

local defaultWalkAnimation = walkAnimationObject.AnimationId
local defaultRunAnimation = runAnimationObject.AnimationId
local defaultIdleAnimation = idleAnimationObject.AnimationId

local idleAnimationId = "http://www.roblox.com/asset/?id=507766388" -- Your idle animation id
local walkAnimationId = "http://www.roblox.com/asset/?id=913376220" -- Your walk animation id

local function changeAnimation()
	
	local health = humanoid.Health
	
	if health <= 25 then
		humanoid.WalkSpeed = 8
		idleAnimationObject.AnimationId = idleAnimationId
		walkAnimationObject.AnimationId = walkAnimationId
		runAnimationObject.AnimationId = walkAnimationId
	else
		humanoid.WalkSpeed = 16
		idleAnimationObject.AnimationId = defaultIdleAnimation
		walkAnimationObject.AnimationId = defaultRunAnimation
		runAnimationObject.AnimationId = defaultRunAnimation
	end
end

humanoid:GetPropertyChangedSignal("Health"):Connect(changeAnimation)
4 Likes

Oooh it works thx so much for the help!!

1 Like