i feel using if statements is a bad idea and will cause alot of bugs so what can i use instead that would be easier and less buggy
COMMUNITY QUESTION
what can i use for when a humanoids health changes?
1 answer
ROBLOX has a specific event for this called HealthChanged. It does exactly what it suggests: fires when the player's health changes. It's really easy to use;
local player=game.Players.LocalPlayer
local humanoid=player.Character.Humanoid
local currentHealth=humanoid.Health --getting the current health
humanoid.HealthChanged:connect(function(health) --Passes the parameter "health". It's just what it changed to
local change=math.abs(currentHealth-health) --Getting the absolute value (Humanoid health is usually a decimal)
print(player.Name.."'s health "..(currentHealth>health and "decreased by " or "increased by ")..change.."!") --This will tell you whether the health increased or decreased
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It sounds like you need the humanoid.changed event, but you need to be more specific if you want anything else. Also, read the guide for asking question. Give us a bit of code that you tried.