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 change the text in a text label?

gui = game.StarterGui.ScreenGui
label = game.StarterGui.ScreenGui.TextLabel
val = label.important
val.Value = 2

while true do
label.Text = val.Value
	val.Value = val.Value + 1
	wait(1)
	print(val.Value)
end

this is supposed to change the label text, but it doesnt. it prints all the numbers correctly, but how do i change the text. i've tried this exact code with a string value, and a number value.

2 answers

✓ Accepted answer

When changing TextLabel text, first of all, make sure it is a LocalScript changing it.

Secondly, TextLabel text is a String, not an Integer.

To convert an integer to a string, you would use tostring()

gui = game.StarterGui.ScreenGui
label = game.StarterGui.ScreenGui.TextLabel
val = label.important
val.Value = 2

while true do
label.Text = tostring(val.Value) --Make sure val.Value is a string.
    val.Value = val.Value + 1
    wait(1)
    print(val.Value)
end
local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("ScreenGui")
local label = gui.TextLabel
local val = label.important

while true do
label.Text = "" ..val.Value -- i did ..val.Value so the text can pick up the value
val.Value = val.Value + 1
wait(1)
print "" ..val.Value
end

Try it now

1 comment

1

it doesnt work

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