Start typing to search packages!
simpleleaderboard
By @lucasx150
Roblox
MirroredSimpleLeaderboard
Global leaderboards - minimal setup required, but fully customizable if needed.
Usage
local SimpleLeaderboard = require(ReplicatedStorage.Packages.SimpleLeaderboard)
SimpleLeaderboard.new({
Name = "Cash",
GetStat = function(player)
return MyDataLayer.Get(player, "Cash")
end,
Renderer = SimpleLeaderboard.BoardRenderer.new({
Container = leaderboardGui.Frame.ScrollingFrame,
Template = ReplicatedStorage.Templates.LeaderboardEntry,
}),
})
The board starts automatically, saving online players' Cash
every SaveInterval seconds and refreshing the UI every UpdateInterval
seconds.
SimpleLeaderboard.new(config: BoardConfig): Board
| Field | Type | Default | Notes |
|---|---|---|---|
Name | string | required | Used as the OrderedDataStore name unless OrderedStore is given |
GetStat | (Player) -> number? | required | Reads the current stat value for a player |
Renderer | (entries: {LeaderboardEntry}) -> () | none | Updates the Leaderboard UI. Build one with SimpleLeaderboard.BoardRenderer.new(...), or pass your own function. Omit it for a save-only board - no UI update loop runs |
SaveCondition | (value: number) -> boolean | always save | If false, the value will not be saved to the OrderedDataStore |
Serializer | (value: any) -> number | identity | Applied before writing to OrderedDataStore |
Deserializer | (value: number) -> any | identity | Inverse of Serializer, applied when reading entries back |
PageSize | number | 25 | OrderedDataStore page size |
SaveInterval | number (seconds) | 720 | How often players' stats are saved |
UpdateInterval | number (seconds) | 540 | How often the UI is refreshed |
OrderedStore | OrderedDataStore | Based on Name |
Methods
Board:Start()- begins the save loop and the UI update loop. Boards start automatically by default.Board:Stop()- halts both loops; safe toStart()again later.Board:Destroy()- stops and permanently disables the board.
SimpleLeaderboard.BoardRenderer.new(config: RendererConfig): Renderer
Builds a default renderer for a ScrollingFrame of cloned template entries.
| Field | Type | Default | Notes |
|---|---|---|---|
Container | ScrollingFrame | required | |
Template | GuiObject | required unless a default is set | Needs Title/Rank/Value descendants for the default GuiFormatter |
GuiFormatter | (GuiObject, entry: LeaderboardEntry) -> () | fills Title/Rank/Value, top-3 gold/green/teal highlight | Fills in a player's leaderboard entry - both its text and its appearance. The deserialized value is entry.Value |
BoardRenderer.SetDefaultTemplate(template: GuiObject)- sets a fallbackTemplateso it doesn't need to be passed to everyRendererConfig.BoardRenderer.SetDefaultGuiFormatter(formatter: GuiFormatter)- same, forGuiFormatter.BoardRenderer.DefaultGuiFormatter- the built-in formatter, so a custom one can call it and then adjust.
SimpleLeaderboard.Serialize
Pairs of (Serializer, Deserializer) for stats that don't fit directly into an OrderedDataStore's integer storage:
Serialize.Log(precision: number?)- stores vialog10, for stats that can exceed2^63(e.g. cash). Lossy pastprecisiondigits.Serialize.Negatives(bias: number?)- shifts negative-capable stats into non-negative range.Serialize.Divide(factor: number?)- divides by a fixed factor, for stats with more precision than integer storage allows (e.g. thousandths).
SimpleLeaderboard.StatSource
A helper for data layers that store multiple stats under one general accessor
(e.g. ProfileStore-style profile.Data[key]). Wrap it once and get a
GetStat function per key, instead of writing a closure for every board.
local stats = SimpleLeaderboard.StatSource.new(function(player, key)
local profile = ProfileStore:GetProfile(player)
return profile and profile.Data[key]
end)
SimpleLeaderboard.new({
Name = "Cash",
GetStat = stats:GetStat("Cash"),
...
})
SimpleLeaderboard.new({
Name = "Rebirths",
GetStat = stats:GetStat("Rebirths"),
...
})
StatSource.new(source: (Player, key: string) -> number?): StatSourceStatSource:GetStat(key: string): StatGetter- returns a(Player) -> number?bound tokey, for use as aBoardConfig.GetStat.
Package Details
Install command (Click to copy)
Version
0.1.1
License
MIT
Safe for commercial use
The package archive does not include its license text; the license is declared in its manifest metadata.
Automated license review — not legal advice.
