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

(SOLVED) How do you change a TextLabel's text in a local script?

I have a LocalScript inside a GUI. I am trying to change the text of a TextLabel. I want the text to say: $0 / $4000. It only says 0. (That's the text it is before playing.)

This is the LocalScript:

local player = game.Players.LocalPlayer
local cashCollected = player:WaitForChild("CashCollected")
local storage = player:WaitForChild("Storage")

script.Parent.RewardText.Text = "$"..cashCollected.Value.."/"..storage.Value

cashCollected:GetPropertyChangedSignal("Value"):Connect(function()
	script.Parent.RewardText.Text = "$"..cashCollected.Value.." / $"..storage.Value
end)

Any help?

1 answer

✓ Accepted answer

From a LocalScript, you can access the LocalPlayer's PlayerGui and make edits from there:

local player = game.Players.LocalPlayer
local cashCollected = player:WaitForChild("CashCollected")
local storage = player:WaitForChild("Storage")

player.PlayerGui.ScreenGui.RewardText.Text = "$"..cashCollected.Value.."/"..storage.Value -- Fix #1

cashCollected:GetPropertyChangedSignal("Value"):Connect(function()
	player.PlayerGui.ScreenGui.RewardText.Text = "$"..cashCollected.Value.." / $"..storage.Value -- Fix #2
end)

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