I don’t get why this piece of code is wrong. Im not the best scripter. 
1 Like
Updated it, still not working. 
Capitilize Humanoid and Health
Other than that it looks fine.
It still doesn’t work. Hmmm. Im not sure.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local function onHealthChanged(health)
if health <= 20 then
humanoid.WalkSpeed = 2
else
humanoid.WalkSpeed = 16
end
end
humanoid.HealthChanged:Connect(onHealthChanged)
3 Likes
Oh wait, I just realized you’re trying to reference a Humanoid in the Player try getting the character first, my bad.
You can get the character trough game.Players.LocalPlayer.Character or player.OnPlayerAdded()
2 Likes
Wait its probably because im healing. How can i disable healing?
Try this:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function(health)
humanoid.WalkSpeed = 8 + (8 * health / humanoid.MaxHealth)
end)
Put an empty script inside of starter character and name it “Health”
2 Likes
.HealthChanged is superior in this case. Use that instead.
Thank you, I’ll edit my script.
1 Like