How to make text show number

Hi, idk what its called but i want my text to show numbers i already have that but like it goes 1000000 instead of like 1M and it goes like 10000 instead of 10K and stuff heres my script:

local Player = game.Players.LocalPlayer

local Money = Player:WaitForChild("leaderstats"):WaitForChild("Cash")

script.Parent.Text = "Cash:" ..Money.Value

Money.Changed:Connect(function()
	script.Parent.Text = "Cash:" ..Money.Value
end)
1 Like

try this

local Player = game.Players.LocalPlayer
local Money = Player:WaitForChild("leaderstats"):WaitForChild("Cash")

local function formatNumber(num)
	if num >= 1_000_000 then
		return string.format("%.1fm", num / 1_000_000) 
	elseif num >= 1_000 then
		return string.format("%.1fk", num / 1_000) 
	else
		return tostring(num)
	end
end

script.Parent.Text = "Cash: " .. formatNumber(Money.Value)

It gives me a error "script.Parent.Text = “Cash: " .. formatNumber(Money.Value)” also i put it in a local script

That’s not an error. Probably “Money” doesn’t exist or “script.Parent” isn’t a TextGUI.

Can you show me the error? I can’t help unless I know whats wrong

local Player = game:GetService("Players").LocalPlayer

local Money = Player:WaitForChild("leaderstats"):WaitForChild("Cash")

local TextLabel:TextLabel = script.Parent

Money.Changed:Connect(function():()
	TextLabel.Text = "Cash:" .. tostring(Money.Value)
end)
TextLabel.Text = "Cash:" .. tostring(Money.Value)
1 Like

Cause that how it works.
CoreGUI responsible for rounding is internal and you are using custom UI for that, there so you have to make formatting yourself.