Weird issue with textlabel


I made a script that shows the total coins a player has in a textlabel, however the weird thing is, the textlabel’s information gets updated when player joins the game in studio, but it’s not getting updated in roblox game. It stays as 0 until the value gets changed. I haven’t encountered anything like this before. Any feedbacks on this?


Hi, I don’t see anything specifically wrong with it but have you tried putting some prints in the


to see what its trying to set those values to and if it is even getting there?

Also I notice that you’re using game.Players alot, If you made:

local PS = game:GetService("Players")

You could shorten the game.Players to PS

1 Like

I added a print(“Values entered!”) at the end of the first function, and I couldn’t see any prints at the output. Weird thing is, the value is entered perfectly fine on studio, but not on roblox launcher. So weird

Roblox Studio play mode are truly something else and you must work around it by yourself, things are loaded in fast speed so it’s normal for some functions to run before you expect them.

Try running some :WaitForChild() on PlayerGui and your ScreenGui first before settings the values.
Aswell making update function as such;

-- loading the player
local players = game:GetService("Players")
local client = players.LocalPlayer
local playerGui = client:WaitForChild("PlayerGui")

-- loading the gui
local coinLabel = script.Parent:WaitForChild("TextLabel")
local gemsLabel = script.Parent.Parent:WaitForChild("GemsLabel"):WaitForChild("TextLabel")

-- loading leaderstats
local leaderstats = client:WaitForChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
local gems = leaderstats:WaitForChild("Gems")

-- creating functions
function updateBalance()
    coinLabel.Text = coins.Value or 0
    gemsLabel.Text = gems.Value or 0
updateBalance() -- update it first

-- creating signals

please let me know if it still doesn’t work.

Also forgot to mention, what kind of script did you use? where do you place the script?

1 Like

This post may also be of some help:

1 Like

When you are in your game what is the output of the console? Press F9 or type /console in chat to open the developer console. Screenshot the contents of the console and show us.

1 Like

the function PlayerAdded only works only if you make the script run before the player joins.
In this case it doesn’t ran meaning the player has joined before the script executed. No, even more correct, the signal is placed after the player joined

That’s why I always do this on Player related functions

local players = game:GetService("Players")
for _, player in ipairs(players:GetChildren()) do
1 Like

Same issue again, I applied your method, sadly it did not work.

What script did you use for running the script? And where do you place it?

1 Like

I’m using a localscript inside a GUI.

Output console isn’t showing anything more than infinite yield possible error on one of my scripts.

Yup, This is exactly why I prefer to just access the Local player directly instead of using the PlayerAdded event on the client. Especially if your only goal is to display information about the local player.

1 Like

Have you tried running the update function before adding signal? because it won’t update at first until it updates

1 Like