Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a saving leaderboard?

Asked by 4 years ago

So im pretty new to scripting and trying to get down the basics. I've been trying to make a saving leader board but everything ive found doesnt work or doesnt save.

I've got this so far.

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("MoneySaveSystem")

But not too much

1 answer

Log in to vote
0
Answered by 4 years ago

This is a pretty simple process, I have no idea where you have been looking but the script is everywhere and works from what I know. But here is the one I use, I have changed everything to money because thats what you used above.

--> Locations

local DataStore = game:GetService("DataStoreService") --> Place to store Data.
local ds = DataStore:GetDataStore("MoneySaveSystem") --> Feel free to change Coins to your save system name

--> Leaderboard

game.Players.PlayerAdded:connect(function(player)
    local leader = Instance.new("Folder",player)
    leader.Name = "leaderstats" --> Makes the leaderboard.
    local Money = Instance.new("IntValue",leader)
    Money.Name = "Money" --> Change "Money" to your currency.
    Money.Value = ds:GetAsync(player.UserId) or 0
    Money.Changed:connect(function()
        ds:SetAsync(player.UserId, Money.Value) --> Finds players leaderboard Data.

    end)
end)

game.Players.PlayerRemoving:connect(function(player)
    ds:SetAsync(player.UserId, player.leaderstats.Money.Value) --> Finds players leaderboard Data and gives it them.
end)

I am aware that the details on that aren't 100% correct but I haven't got round to changing them from my script.

If you have any issues feel free to reply to this.

0
Thanks, it works Axie_1xDeath 0 — 4y
Ad

Answer this question