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

How do you correctly update a textLabel?

Asked by 5 years ago

I'm making a game where a player has items, and I'm brand new to scripting. The items variable is global so every script I have can access them, and I'm trying to set a textLabel's text (The script's parent is the textLabel) to my items variable and it's not working!!! What am I doing wrong?

Here is my code:

_G.items = 0
local textLabel = script.Parent
textLabel.Text = _G.items
0
change it through the player gui DeceptiveCaster 3761 — 5y
0
is there any output? User#25606 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

A very inefficient but tolerable way would be: putting a LocalScript inside the textlabel and update the text every frame.

game:GetService("RunService").RenderStepped:connect(function()
    script.Parent.Text = tostring(_G.items)
end)
Ad

Answer this question