[SOLVED] Text not updating

Hello so i have a Gui with a text in it and its supposed to update every frame. But it doesnt, can someone help.

Here is my code:

local Player = game.Players.LocalPlayer
local leaderstats = Player.leaderstats

task.wait(1)

local T = {“K”,“M”,“B”,“T”,“q”,“Q”,“s”,“S”,“O”,“N”,“d”,“U”,“D”}
local function formatNumber(n)
if not tonumber(n) then return n end
if n < 10000 then return math.floor(n) end
local d = math.floor(math.log10(n)/3)*3
local s = tostring(n/(10^d)):sub(1,5)
return s…" "…tostring(T[math.floor(d/3)])
end

local Coins = leaderstats.Coins.Value
local Strength = leaderstats.Strength.Value

game:GetService(“RunService”).RenderStepped:Connect(function()
script.Parent.Coins.Inside.CoinsText.Text = formatNumber(Coins)
script.Parent.Strength.Inside.StrengthText.Text = formatNumber(Strength) … “/Inf”
end)
1 Like

Does it say any error? or something and why did you use format

Can I ask why you are updating a label every frame? What is it’s purpose? There may be a more efficient way.

I’ve tried using .Changed but it this didnt work

No error, its more convinient for players to look at 100K instead of 100000

Try using a while loop and make sure its a local script. Hope this helps :smile:

Still the same thing, i used a while loop and it is a local script. Also it updates only once and doesnt update anymore when i join the game it updates and then it doesnt

Because you don’t update the Coins and Strength variable lol

1 Like

Oh my god, thank you so much. My brain wasnt braining

can you give me the solution :innocent::innocent:

local Player = game.Players.LocalPlayer
local leaderstats = Player.leaderstats

task.wait(1)

local T = {"K","M","B","T","q","Q","s","S","O","N","d","U","D"}
local function formatNumber(n)
	if not tonumber(n) then return n end
	if n < 10000 then return math.floor(n) end
    local d = math.floor(math.log10(n)/3)*3
    local s = tostring(n/(10^d)):sub(1,5)
    return s.." "..tostring(T[math.floor(d/3)])
end

local Coins = leaderstats.Coins.Value
local Strength = leaderstats.Strength.Value

script.Parent.Coins.Inside.CoinsText.Text = formatNumber(Coins)
script.Parent.Strength.Inside.StrengthText.Text = formatNumber(Strength) .. "/Inf"

leaderstats.Coins:GetPropertyChangedSignal("Value"):Connect(function()
	Coins = leaderstats.Coins.Value
	Strength = leaderstats.Strength.Value
	script.Parent.Coins.Inside.CoinsText.Text = formatNumber(Coins)
end)

leaderstats.Strength:GetPropertyChangedSignal("Value"):Connect(function()
	Coins = leaderstats.Coins.Value
	Strength = leaderstats.Strength.Value
	script.Parent.Strength.Inside.StrengthText.Text = formatNumber(Strength) .. "/Inf"
end)

modify using this:

local Player = game.Players.LocalPlayer
local leaderstats = Player.leaderstats

task.wait(1)

local T = {“K”,“M”,“B”,“T”,“q”,“Q”,“s”,“S”,“O”,“N”,“d”,“U”,“D”}
local function formatNumber(n)
if not tonumber(n) then return n end
if n < 10000 then return math.floor(n) end
local d = math.floor(math.log10(n)/3)*3
local s = tostring(n/(10^d)):sub(1,5)
return s…" "…tostring(T[math.floor(d/3)])
end

local Coins = leaderstats.Coins.Value
local Strength = leaderstats.Strength.Value

while true do
script.Parent.Coins.Inside.CoinsText.Text = formatNumber(Coins)
script.Parent.Strength.Inside.StrengthText.Text = formatNumber(Strength) … “/Inf”
wait(0.001) -- Time between updates
end

It’s already solved why are you spamming your solution? Also your method is worse than the original solution

3 Likes