so i tried making a script that detects when the player's health decreases, but i kept getting "attempt to compare number < boolean". i'm pretty sure the boolean value is "newHealth", but how can that be a boolean value? here's the code (it's a local script, in StarterCharacterScripts)
local char = script.Parent local hum = char:FindFirstChild("Humanoid") local oldHealth = hum.Health hum.HealthChanged:Connect(function(newHealth) if math.abs(oldHealth - newHealth) <= 10 > 1 then --code end end)
thanks in advance
Nevermind, I had to change the if statement to this
if math.abs(oldHealth - hum.Health) <= 10 and math.abs(oldHealth - hum.Health) > 1 then --code end
What XD_Destroyer1234 meant:
local char = script.Parent local hum = char:FindFirstChild("Humanoid") local oldHealth = hum.Health if math.abs(oldHealth - hum.Health) <= 10 and math.abs(oldHealth - hum.Health) > 1 then --code end
WARNING: DO ACCEPT THIS ANSWER
lol