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

How do I output the value of a variable in textlabel?

Google translator, sorry

local value = workspace.PlayerValues.BrownMaterial.Value

while true do 
	game.StarterGui.HudGui.MainFrame.PlayerStats.BrownMaterial.Text = value
	wait()
end

I showed the value of a variable, everything is OK, but if it changes, the text of the textlabel remains the same

1 answer

✓ Accepted answer

The StarterGui holds GUIs to be later copied and given to players when they spawn.

There is no point in your scripts changing its contents.


You should use a LocalScript and modify the current player's GUI:

-- I assume that this script is a child of "HudGui":

local value = workspace.PlayerValues.BrownMaterial.Value

while true do
	script.Parent.MainFrame.PlayerStats.BrownMaterial.Text = value
	wait()
end

However, you never "refresh" value -- the script saves the value that it was when it sets value = .......

You need to grab value again in each iteration of the while loop if you want to show the "live" value:


while true do
	local value = workspace.PlayerValues.BrownMaterial.Value
	script.Parent.MainFrame.PlayerStats.BrownMaterial.Text = value
	wait()
end

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