Have you ever seen a Leaderboard in a Roblox game before and you want to know how to make it?
Well in today's tutorial I'll show you how to do just that!
Step 1[]
We'll first start off by making code that tells the game to do something once someone enters your game
game.Players.PlayerAdded:Connect(function(Player)
end)
Step 2[]
Next up we'll created a brand new Folder.
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("Folder")
end)
Step 3[]
Then we'll name this Folder "leaderstats". (It has to be EXACTLY as stated otherwise it won’t work properly.)
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("Folder")
Stat.Name = "leaderstats"
end)
Step 4[]
After that we'll create a new IntValue and set its name and value.
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("Folder")
Stat.Name = "leaderstats"
local Score = Instance.new("IntValue")
Score.Name = "Stage"
Score.Value = 0
end)
Step 5[]
Lastly we'll call the parents to both Stat and Score.
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("Folder")
Stat.Name = "leaderstats"
local Score = Instance.new("IntValue")
Score.Name = "Stage"
Score.Value = 0
Score.Parent = Stat
Stat.Parent = Player
end)
Final Results[]
Now you have a working Leaderboard inside of your game, if you want to know how to save your leaderboard stats check out this tutorial.
Small Notes/Tips[]
You can add the parent within the Instance.new() by adding it like so down below:
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("Folder", Player)
Stat.Name = "leaderstats"
local Score = Instance.new("IntValue", leaderstats)
Score.Name = "Stage"
Score.Value = 0
end)
You can also make multiple stats to the leaderboard! Just. Don’t overdo it (Also you aren’t limited to just Int Values!):
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("Folder", Player)
Stat.Name = "leaderstats"
local Score = Instance.new("IntValue", leaderstats)
Score.Name = "Stage"
Score.Value = 0
local Rank = Instance.new("StringValue", leaderstats)
Rank.Name = "Rank"
Rank.Value = "Cool Guy"
end)
