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

how to display a value on a surface gui?

while true do
	wait(1)
script.Parent.Text = "heat.."(workspace.Heat.Value)"
end

2 answers

You have to first add a TextLabel to a SurfaceGui, then you have to add a localscript inside the text label. In the localscript, add:

while wait(0.01) do
	script.Parent.Text = workspace.Heat.Value
end

You had it right, just don't use while true since that can crash the game.

I would do something else than a loop.

Instead of doing a loop and slowing down the game, use .Changed. It will prevent from doing loops for no reason

workspace.Heat.Changed:Connect(function()
	script.Parent.Text = "Heat: "..workspace.Heat.Value
end)

Or use GetPropertyChangedSignal

workspace.Heat:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.Text = "Heat: "..workspace.Heat.Value
end)

I would use these over a while loop and technically, it would change it instantly after it changed and not "0.01" seconds

1 comment

0

GetPropertyChangedSignal is better than Changed

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