LeaderstatsList Module - Streamlined Player Leaderstat Management
Simplify Leaderstat Creation!
Hey y’all! Decided to post my LeaderstatsList module. Enjoy!
What is LeaderstatsList?
LeaderstatsList is a Luau module that tries streamlining the creation and management of player leaderstats in your Roblox games. No more annoying manual Instance creation or worrying about data type compatibility - this module handles it all automatically!
Key Features
- Automatic Type Detection - Automatically converts numbers, strings, and booleans to their respective ValueBase instances
- Custom Ordering - Control the exact order your leaderstats appear with optional ordering system
- Conflict Resolution - Handles property name conflicts with Folder instances
- Typed - Type safety with generics support
- Streamlined Cleanup - Built-in methods for emptying and destroying leaderstat data
Quick Start Example
local LeaderstatsList = require(path.to.LeaderstatsList)
-- Create leaderstats for a player
local playerStats = LeaderstatsList.new(player, {
Cash = 1000,
Level = 1,
Premium = true,
Kills = 0
}, {"Cash", "Level", "Premium", "Kills"}) -- Optional ordering
-- Fill all leaderstats at once
playerStats:FillAll()
-- Or add individual stats
playerStats:FillOne("Coins", 50)
API Reference
Constructor
LeaderstatsList.new<T>(player: Player, data: T, order: {string}?) -> LeaderstatsList<T>
Methods
:FillAll()- Creates all leaderstat instances from the data table:FillOne(name: string, value: any)- Adds a single leaderstat value:GetData()- Returns the current data table:Empty()- Removes all leaderstat instances:Destroy()- Cleans up the entire LeaderstatsList object
Supported Data Types
| Lua Type | Roblox Instance |
|---|---|
| number | NumberValue |
| string | StringValue |
| boolean | BoolValue |
Neat Features
Smart Conflict Resolution: If your leaderstat names conflict with Folder properties, the module automatically appends "Stat" to the name and logs a warning.
Flexible Ordering: The optional order parameter ensures your leaderstats appear in exactly the sequence you want. Missing keys are automatically appended to the end.
Type Safety: Full generic type support means you get proper IntelliSense and type checking in your IDE.
Installation
You can get the module on the Roblox Library here: LeaderstatsList
Feedback
If a bug is found, please don't be afraid to comment or reach out to me! This module is designed to make leaderstat management as painless as possible.
Made by RobloxJrTrainer - (Feel free to use it anywhere and modify it)!