-- Configuration
-- The suffixes for abbreviation in every power of thousands.
local COMPACT_SUFFIX = {
"K", "M", "B", "T"
}
local CACHED_SKELETON_SETTINGS = true
--
local MainAPI = require(script.Parent.Main)
local FormatNumberSimpleAPI = { }
local SKELETON_CACHE = if CACHED_SKELETON_SETTINGS then { } else nil
local COMPACT_SKELETON_CACHE = if CACHED_SKELETON_SETTINGS then { } else nil
function FormatNumberSimpleAPI.Format(value: number, skeleton: string?): string
local success
local formatter = nil
assert(type(value) == "number", "Value provided must be a number")
if skeleton == nil then
skeleton = ""
end
assert(type(skeleton) == "string", "Skeleton provided must be a string")
if CACHED_SKELETON_SETTINGS then
formatter = SKELETON_CACHE[skeleton]
end
if not formatter then
success, formatter =
MainAPI.NumberFormatter.forSkeleton(skeleton)
assert(success, formatter :: string)
if CACHED_SKELETON_SETTINGS then
SKELETON_CACHE[skeleton] = formatter
end
end
return (formatter :: MainAPI.NumberFormatter):Format(value)
end
function FormatNumberSimpleAPI.FormatCompact(value: number, skeleton: string?): string
local success
local formatter = nil
assert(type(value) == "number", "Value provided must be a number")
if skeleton == nil then
skeleton = ""
end
assert(type(skeleton) == "string", "Skeleton provided must be a string")
if CACHED_SKELETON_SETTINGS then
formatter = COMPACT_SKELETON_CACHE[skeleton]
end
if not formatter then
success, formatter =
MainAPI.NumberFormatter.forSkeleton(skeleton)
assert(success, formatter :: string)
formatter = (formatter :: MainAPI.NumberFormatter)
:Notation(MainAPI.Notation.compactWithSuffixThousands(COMPACT_SUFFIX))
if CACHED_SKELETON_SETTINGS then
COMPACT_SKELETON_CACHE[skeleton] = formatter
end
end
assert(#COMPACT_SUFFIX ~= 0, "Please provide the suffix abbreviations for FormatCompact at the top of the Simple ModuleScript")
return formatter:Format(value)
end
return table.freeze(FormatNumberSimpleAPI)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local FormatNumber = require(ReplicatedStorage.Libs.FormatNumber.Simple)
local Remotes = ReplicatedStorage.Remotes
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Gui = PlayerGui:WaitForChild("Left")
local Frame = Gui.Frame.Rebirths
local Rebirths = Frame.Amount
local REBIRTH_TEXT_TEMPLATE = "Rebirth: AMOUNT"
local function UpdateRebirths(amount: number)
Rebirths.Text = REBIRTH_TEXT_TEMPLATE:gsub("AMOUNT", FormatNumber.FormatCompact(amount))
end
UpdateRebirths(Remotes.GetData:InvokeServer("Rebirths"))
Remotes.UpdateRebirths.OnClientEvent:Connect(UpdateRebirths)
Shinies:
local function UpdateCurrency(currency: "mony" | "shinies", amount: number)
if currency == "mony" then
UpdateClicksPerSecond(amount)
mony.Text = FormatNumber.FormatCompact(amount)
elseif currency == "shinies" then
shinies.Text = FormatNumber.FormatCompact(amount)
end
end
UpdateCurrency("mony", Remotes.GetData:InvokeServer("mony"))
UpdateCurrency("shinies", Remotes.GetData:InvokeServer("shinies"))
Remotes.UpdateMony.OnClientEvent:Connect(function(amount)
UpdateCurrency("mony", amount)
end)
Remotes.UpdateShinies.OnClientEvent:Connect(function(amount)
UpdateCurrency("shinies", amount)
end)
The GetData RemoteFunction may be returning nil or something else that isn’t a number, maybe that check and provide it if you can’t figure out what’s wrong?