Do you ever join cafe games? Homestores? Maybe even simulators? What is the first thing you do when you join the game? LOOK AT THE LEADERBOARD
Although leaderboards don't get as much credit as they should, and you think they are in every game? They are a nice way of keeping track of ranks, how many coins someone has, and how far someone is in a game. Who knows what you can do.
In this tutorial, I will be showing you how to make a leaderboard that keeps track of leaderstats every player in the server has.
You are probably tired of me talking. Lets gets started!
This section will teach you how to make your average leaderboard.
In the Explorer tab, under ServerScriptService, create a new script named PlayerSetup.
Next, go into that script and add a function named onPlayerJoin() with a parameter named player.
local function onPlayerJoin(player)
end
In onPlayerJoin(), create a variable named leaderstats as a new Folder instance. All the stats for the player will be stored in this folder.
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
end
Name the folder leaderstats and parent it to the player. If the folder is not named leaderstats, Roblox Studio won’t be alerted to create a leaderboard.
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end
After the closing end of the function, connect onPlayerJoin() to the PlayerAdded event. Whenever a player joins the game, the onPlayerJoin() function will run.
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
Now that the leaderboard script is done, time to add the stats.
WARNING: IF YOU SKIP THIS PART, YOUR LEADERBOARD WON'T WORK
In onPlayerJoin(), under leaderstats.Parent = player, create a new variable. You can choose a name. I will choose "Gold".
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
end
Type gold.Name = "Coins". This is the name that will appear in the leaderboard. You may change it to anything.
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
gold.Name = "Coins"
end
If you don't want the players to start with any currency, add gold.Value = 0
If you want the players to start with some currency, change it to gold.Value = 250 However much you want everyone to start with.
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
gold.Name = "Coins"
gold.Value = 0
end
Type gold.Parent = leaderstats. This parents the IntValue for gold to leaderstats.
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
gold.Name = "Coins"
gold.Value = 0
gold.Parent = leaderstats
end
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
gold.Name = "Coins"
gold.Value = 0
gold.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
WARNING: DOSEN'T SAVE
The diffuculty is set to easy, so this currently does not explain how to save. If the rating for this tutorial is over 4 stars, I will make a tutorial for how to save the leaderstats.
Thanks for all your support, this is my first tutorial. I will hopefully maybe make a series that will make whatever you guys suggest. The best way to contact me is through roblox messaging. I will make any tutorial you guys like! :)
Made by Aidan29251 & GRRROI
This was created on December 22, 2019