https://www.youtube.com/watch?v=D3SS1Wrxbl4&feature=youtu.be
U MUST WATCH
local ds = game:GetService("DataStoreService")
local coinsODS = ds:GetOrderedDataStore("officialpointfortlolSaveSystem")
local timeUntilReset = 100
while wait(1) do
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
if timeUntilReset == 0 then
timeUntilReset = 100
for i, plr in pairs(game.Players:GetPlayers()) do
coinsODS:SetAsync(plr.UserId, plr.leaderstats.Changes.Value)
end
for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = coinsODS:GetSortedAsync(false, 50)
local coinsPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(coinsPage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
local coins = dataStored.value
local template = script.Template:Clone()
template.Name = name .. "Leaderboard"
template.PlrName.Text = name
template.Rank.Text = "#" .. rankInLB
template.Coins.Text = coins
template.Parent = script.Parent
end
end)
end
end
Ok, so what I am trying to do is save the global leaderboard, because if i leave on the 1 player server after the leaderboard loads in, then it does not save, and I wonder if this leaderboard happens through all servers too.
Someone said something about :BindToClose() but they didnt say where or how to really use it.

3 comments
If all players leave the game then you can use :BindToClose() to save all of their data before the server closes.
You can search for things (including BindToClose) at: https://developer.roblox.com/ ex, if you search BindToClose, the first result is DataModel:BindToClose(), which is the correct one, and even comes with examples: https://developer.roblox.com/en-us/api-reference/function/DataModel/BindToClose
What is the problem at-hand??