Leaderstats
Method
Leaderstats displays a leaderstat value on a text element and updates it automatically when it changes.
Overview
The Leaderstats Method reads a value from the player's leaderstats folder and displays it on a text element. It also listens for changes — whenever the leaderstat value updates, the text updates instantly.
Setup
- Add the
UiUtilstag on your text element - Add Attribute
Method=Leaderstats - Add Attribute
ObjectNamewith the name of the leaderstat you want to display
Attributes
| Attribute | Type | Required | Default | Description |
|---|---|---|---|---|
ObjectName |
String | Yes | — | The name of the value inside leaderstats (e.g. Coins, Kills, Level) |
FormatedText |
String | No | — | A format string where %s is replaced by the value. For example, Coins: %s becomes Coins: 150 |
Examples
Show a player's coins:
- Tag:
UiUtils Method=LeaderstatsObjectName=Coins
Show formatted kills:
- Tag:
UiUtils Method=LeaderstatsObjectName=KillsFormatedText=Kills: %s
Notes
- The instance must have a
Textproperty (TextLabel,TextButton,TextBox) - The player must have a
leaderstatsfolder — UiUtils waits up to 20 seconds for it to appear - The value inside
leaderstatsmust match theObjectNameexactly (case-sensitive) - The text updates in real time whenever the leaderstat value changes
- The connection is automatically cleaned up when the instance is destroyed
- If
ObjectNameis missing:No ObjectName attribute found for leaderstats - If the value doesn't exist in leaderstats:
No object found with the name: ...