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 .

3 comments
So in your health 3,2,1 system, is it based on how much health the player has? like in the default health bar?
Also is this a server, or a local script?
yeah it is based off of how much health the players has also it is a local script that i put in under the imagelabel in starter gui