Open Source Leaderstats Script
- Asporus
- Aug 9, 2020
- 1 min read
Leaderstats are very simple, and most developers that have developed for at least a week have learned them. Some new people, though, might wanna learn. Leaderstats are practically the things you see on a leaderboard. Not your name, stuff such as "Kills", "Deaths", "Coins", "Cash", etc.
This is a tutorial on how to do it where it doesnt go on the leaderboard, but still stores your stats into the player. (No datastore.)
local Player = game.Players.LocalPlayer
local Stat1 = Instance.new("NumberValue",Player)
local Stat2 = Instance.new("NumerValue",Player)
Stat1.Value = 0
Stat2.Value = 0
Stat1.Name = "Stat1"
Stat2.Name = "Stat2"
Very simple instancing. If you wanted to define these stats in another script, simply do this:
local Player = game.Players.LocalPlayer
local Stat1 = Player:WaitForChild("Stat1")
local Stat2 = Player:WaitForChild("Stat2")
If you would like these stats to be in a folder inside of the player, simply do the same script at the very top just like this
local Player = game.Players.LocalPlayer
local StatFolder = Instance.new("Folder",Player)
local Stat1 = Instance.new("NumberValue",StatFolder)
local Stat2 = Instance.new("NumerValue",StatFolder)
Stat1.Value = 0
Stat2.Value = 0
Stat1.Name = "Stat1"
Stat2.Name = "Stat2"
Comments