local player = game.Players.LocalPlayer local humanoid = player.Character.Humanoid local currentHp = humanoid.Health humanoid.HealthChanged:connect(function(health) print(currentHp) if health < currentHp then script.Parent:WaitForChild("RemoteEvent"):FireServer(health) end end)
Whenever I use this script the currentHp printed is 100. Is there any way to fix this?
Try putting the line local currentHp = humanoid.Health
inside the function.
local player = game.Players.LocalPlayer local humanoid = player.Character.Humanoid humanoid.HealthChanged:connect(function(health) local currentHp = humanoid.Health print(currentHp) if health < currentHp then script.Parent:WaitForChild("RemoteEvent"):FireServer(health) end end)
Always be sure that you check what the health value is after the humanoid takes damage. The way you had it, the script would only check once it ran and never again.