Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script is not updating the text please help me and why is it not working?

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false) -- This Will Disable the Roblox Health GUI

--Variables
local player = game.Players.LocalPlayer
local char = player.Character
local gui = script.Parent
local frame = gui.HealthFrame
local bar = frame.Bar
local text = frame.HealthText

while wait() do
 	--Update text
 	text.Text = "HP: "..math.floor(char:WaitForChild("Humanoid").Health).."/"..char:WaitForChild("Humanoid").MaxHealth
 	-- Update bar
 	bar.Size = UDim2.new(0,(char:WaitForChild("Humanoid").Health / char:WaitForChild("Humanoid").MaxHealth * 200),1,0)
end

1 comment

0

Please embed the script next time

1 answer

You are wating for the Humanoid try using FindFirstChild() instead

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)

local player = game.Players.LocalPlayer
local char = player.Character
local gui = script.Parent
local frame = gui.HealthFrame
local bar = frame.Bar
local text = frame.HealthText

while wait() do 
 text.Text = 
"HP:"..math.floor(char:FindFirstChild("Humanoid").Health).."/"..char:FindFirstChild("Humanoid").MaxHealth
 bar.Size = UDim2.new(0,(char:FindFirstChild("Humanoid").Health / char:FindFirstChild("Humanoid").MaxHealth * 200),1,0)
end

Hope this helps!

1 comment

0

it did not work, I have a text that says Health: 100/100 I am trying to make it respond when you take loose health and it should say like 50/100

This discussion is preserved as it was. New answers, comments, and votes are closed.