Tutorial:How to make a leaderboard!

This tutorial will help you create a leaderboard in no time!

​Step 1: Get services and variables. Type in this:
local DataStore = game:GetService("DataStoreService")

local ds = DataStore:GetDataStore("PointsSaveSystem")

Make sure you change ("PointsSaveSystem") for every value and call it (YourName)SaveSystem

​You can keep DataStoreService though.



​Step 2: Start a function. Type in this:

game.Players.PlayerAdded:connect(function(player)

end

When you do that and press enter an end should appear.



​Step 3: Put this in your function:

game.Players.PlayerAdded:connect(function(player)

local leader = Instance.new("Folder",player)

leader.Name = "leaderstats"

local Points = Instance.new("IntValue",leader)

end

You can change the word "Points" into what stat you want.

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<h3 style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">​Step 4: Complete the function.

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">game.Players.PlayerAdded:connect(function(player)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">local leader = Instance.new("Folder",player)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">leader.Name = "leaderstats"

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">local Points = Instance.new("IntValue",leader)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">Points.Name = "Points" This is the name of your stats

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">Points.Value = ds.GetAsync(player.UserId) or 0

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">ds:SetAsync(player.UserId, Points.Value)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">end

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">Remeber to change "Points" to whatever you like.

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<h3 style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">​Step 5: Add the saving part.

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">game.Players.PlayerRemoving:connect(function(player)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">ds:SetAsync(player.UserId, player.leaderstats.Tix.Value)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">end <h3 style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<h3 style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">Entire script:

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">local DataStore = game:GetService("DataStoreService")

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">local ds = DataStore:GetDataStore("PointsSaveSystem")

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">game.Players.PlayerAdded:connect(function(player)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">local leader = Instance.new("Folder",player)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">leader.Name = "leaderstats"

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">local Points = Instance.new("IntValue",leader)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">Points.Name = "Points"

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">Points.Value = ds.GetAsync(player.UserId) or 0

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">ds:SetAsync(player.UserId, Points.Value)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">end)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">game.Players.PlayerRemoving:connect(function(player)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">ds:SetAsync(player.UserId, player.leaderstats.Points.Value)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">end)

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;-qt-block-indent:0;text-indent:0px;-qt-user-state:0;">