I made a past post which had a bad title, however this script is supposed to change the animation of walking when the character's health is less than or equal to 25. The animation does not change nor does the walk speed change.
local Player = game.Players.LocalPlayer local Character = workspace:WaitForChild(Player.Name) local Humanoid = Character:WaitForChild('Humanoid') if Humanoid.Health <= 25 then Humanoid.WalkSpeed = 8 Character.Animate.walk.WalkAnim.AnimationID = "rbxassetid://" end
I know there is not a id for the animation.
The issue your script has is your check on the Humanoid's health. When the player just spawns, which I assume is when your script starts the check, their health is or should be always equal to MaxHealth. By default, this is 100, not 25 or below.
The below script may work, all I did was fix your way of detecting health being <= 25 and properly using animations. You were doing..something but need to load the animation first, then play it.
local Player = game.Players.LocalPlayer local Character = workspace:WaitForChild(Player.Name) local Humanoid = Character:WaitForChild('Humanoid') local animation = Instance.new("Animation") animation.AnimationId = "rbxassetid://" local HurtWalk = Humanoid:LoadAnimation(animation) Humanoid.HealthChanged:Connect(function(health) if health <= 25 then Humanoid.WalkSpeed = 8 HurtWalk:Play() end end
The event HealthChanged of Humanoid as stated on the wiki: Fires when the Humanoid/Health changes to a value equal or below the Humanoid/MaxHealth value.
If you run into any issues or have any questions, feel free to comment below.