So for this I'm using the default roblox leaderboard. (With the deaths value changed to Ls.) Here's the code on my save script :

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("KillSaveSystem")
local ds2 = datastore:GetDataStore("LSaveSystem")

game.Players.PlayerAdded:connect(function(player)
	local folder = Instance.new("Folder", player)
	folder.Name = "leaderstats"
	local kills = Instance.new("IntValue", folder)
	kills.Name = "Kills"
	local ls = Instance.new("IntValue", folder)
	ls.Name = "Ls"
	
	kills.Value = ds1.GetAsync(player.UserId) or 0
	ds1:SetAsync(player.UserId, kills.Value)
	
	kills.Changed:connect(function()
	ds1:SetAsync(player.UserId, kills.Value)
	
	end)
	
	ls.Changed:connect(function()
	ds2:SetAsync(player.UserId, ls.Value)
		
	ls.Value = ds2.GetAsync(player.UserId) or 0
	ds2:SetAsync(player.UserId, ls.Value)
	
	end)
end)

Any ideas as to why it's not functioning properly?

5 comments

0

Is leaderstats the value itself? Shouldn't the value be inside of leaderstats?

0

So it would be like ls.Insert Value Name Here.Value instead of ls.Value, Right?

0

Also you need to add a load system, right now it doesn't load when you start up, it only loads right after it saves. Make so the leaderstats thing loads like the kills does.

0

So put the :GetAsync() before or after the changed event.

0

its more conventional to save a table of values, rather than saving each value to a separate datastore. ie: local DataToSave = {Level, Money}