Saving and loading leaderboard
I know how to create a leaderboard but I do not know how to save it when a player leaves the game and load when the player rejoins. I am trying to do tutorials but all five of them did not work for me. All I ask is that someone who knows this stuff gives me an answer on how to make a saving and loading leaderboard
my code is down here and this is the tutorial I used for it: https://www.youtube.com/watch?v=lS20iM7iRQE
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("GemSaveSystem") local ds2 = datastore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local gems = Instance.new("IntValue", folder) gems.Name = "Gems" local cash = Instance.new("IntValue", folder) cash.Name = "Cash" gems.Value = ds1:GetAsync(plr.UserId) or 0 ds1:SetAsync(plr.UserId, gems.Value) cash.Value = ds2:GetAsync(plr.UserId) or 0 ds2:SetAsync(plr.UserId, cash.Value) gems.Changed:connect(function() ds1:SetAsync(plr.UserId, gems.Value) end) cash.Changed:connect(function() ds2:SetAsync(plr.UserId, cash.Value) end) end)

3 comments
Are you playing your game in Studio or on Player? If you're doing it in Studio, you have to activate the DataStoreService in game settings.
that indentation is killin me
Lmao