hi im new here and i've been having problems with this certain code that i made (im new at this sorry if it looks bad) the point of the code is to make it so if your health is at for example 3 on starter gui it would display a custom imagelabel. and would apreciate it if someone could help me out with it? for example when the health is at 3 it would display a custom imagelabel that i made that has a 3 on it (the max health is 3)
local guiObject = script.Parent local gui = script.Parent local plr = game.Players.LocalPlayer; local character = plr.Character or plr.CharacterAdded:Wait(); local humanoid = game.Players.LocalPlayer.Character.Humanoid local currentHealth = humanoid.Health local hum = character:WaitForChild("Humanoid"); local function health() if hum.Health == 3 then guiObject.Visible = true else guiObject.Visible = false end humanoid.HealthChanged:Connect(function(health) end)
sorry if it seems messy im new to this all and after trying to search around for a while i just realized that i got no idea .
humanoid:GetPropertyChangedSignal("Health"):Connect(function() if humanoid.Health == 3 then guiObject.Visible = true else guiObject.Visible = false end end)