Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a saving leaderboard?

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

✓ Accepted answer

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.

1 comment

0

Thanks, it works

This discussion is preserved as it was. New answers, comments, and votes are closed.