✓ Accepted answer
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.
1 comment
If you're trying to hide the ID..3303569379 well