Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited by Azarth 5 years ago

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
0
Please embed the script next time stef0206 125 — 5y

1 answer

Log in to vote
0
Answered by
stef0206 125
5 years ago

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!

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 Leqtrix 7 — 5y
Ad

Answer this question