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

how to display a value on a surface gui?

Asked by
hokyboy 270 Moderation Voter
5 years ago
Edited 5 years ago
while true do
    wait(1)
script.Parent.Text = "heat.."(workspace.Heat.Value)"
end

2 answers

Log in to vote
0
Answered by 5 years ago

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.

Ad
Log in to vote
0
Answered by
Creacoz 210 Moderation Voter
5 years ago
Edited 5 years ago

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

0
GetPropertyChangedSignal is better than Changed Trollapse 89 — 5y

Answer this question