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

can someone help w/ the updtating text on a Health Script? thanks!

Asked by
36Hrs 0
6 years ago

local plrs = game:GetService("Players") local plr = plrs.LocalPlayer local character = plr.Character or plr.CharacterAdded:wait() local hum = character:WaitForChild("Humanoid")

local health = hum.Health

local interface = {} do local playerGui = plr:WaitForChild("PlayerGui")

local gui = playerGui:WaitForChild("HealthBar")
local frame1 = gui:WaitForChild("status")
local text = frame1:WaitForChild("healthpercent")
local status = frame1:WaitForChild("overlay")

local Udim2_new = UDim2.new

function interface:UpdateHealth()
    status.Size = Udim2_new(health/100,0,1,0)
    text.Text = ("Health: %d / 100"):format(health)

end

end

interface:UpdateHealth() wait(.5)

It has no errors, but it isn't actually updating the text on the UI itself. Any help is appreciated :)

0
while true do? Astralyst 389 — 6y
0
last line, you can try doing "hum.Health.Changed:connect(interface:UpdateHealth)" Astralyst 389 — 6y
0
try this "while wait() interface:UpdateHealth() do end will update the health. If you do while true do without a wait prob will crash studio in test or make game take forever to load. NovusDev 25 — 6y
0
Or like ast_raa said use humanoid.HealthChanged to detect only if the health changes instead of lagging the game. Ultimate_Piccolo 201 — 6y

Answer this question