character = script.Parent -- The npc
humanoid = character.Major -- Change this to the humanoid name
yellowzone = humanoid.MaxHealth/2 -- for if the npc health is at half
humanoid.Changed:Connect(function()
if humanoid <= yellowzone then -- if the health is 1/2
humanoid.WalkSpeed = 40 -- change speed
elseif humanoid > yellowzone then -- if it's above half health
humanoid.WalkSpeed = 20 -- normal speed
end
end)
since i didn't want to make it so if the health amount is at a specific number it gets faster i wanted to make it so if it's at half or 50% hp it'll change speed but it doesn't seem to work how can i fix this?

2 comments
try putting on line 5 .health next to humanoid
thank you it worked i'm kinda forgetful when it comes to this kind of stuff and i'm still new to coding