Help with GUI text not updating

I’ve been working on an auto updating script that shows the value of the number in the player’s GUI as k(thousand), m(million) and so on. This script is working on two values: one shows what the player currently has and one shows the maximum capacity the player can have.

The problem is that the part that shows the maximum capacity doesn’t update in the game. The script prints show that it’s updated but when checking the player gui and the values inside it’s still unchanged.

For testing i tried to manually change the text value in the player gui and see if the prints recognise the change to make sure that the text is defined correctly but no problem there.

This is the sample of my code.

while true do
    updt = script.Parent
	totaltext = script.Parent.Parent.Total.Text
--these are locally stored values. They will be modified by the server according to data storage
	number = game.ReplicatedStorage.Coins.Value
	total = game.ReplicatedStorage.TotalCoins.Value
--checknum just changes the number to the final text ex:100M. 
	visual = checknum(number)
	vtotal = checknum(total)
	updt.Text = visual
	totaltext = "/"..vtotal
	print(totaltext)
	task.wait(0.2)
end

The updt part works correctly. My problem is with totaltext not updating.

1 Like

Maybe the issue comes from the variable “totaltext”.
Try replacing it by:

totaltext = script.Parent.Parent.Total

And then when you change the actual text do:

totaltext.Text = "/"..vtotal

Because the way you did was retrieving the text from “totaltext” and then changing its value in the script, not in the gui.
This way you define totaltext first and assign its text in the gui.

2 Likes