How to make this also a kills leaderboard

I’m working on this KOTH game and I can’t seem to figure out how to also put in kills and have it save as well. Can you help?

Here is the code:

local ds = game:GetService(“DataStoreService”)
local ds1 = ds:GetDataStore(“CashSaveSystem”)

game.Players.PlayerAdded:connect(function(player)
local fold = Instance.new(“Folder”, player)
fold.Name = “leaderstats”

local Crowns = Instance.new("IntValue", fold)
Crowns.Name = "Crowns"
Crowns.Value = 0

Crowns.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, Crowns.Value)
	
Crowns.Changed:connect(function()
	ds1:SetAsync(player.UserId, Crowns.Value)
end) 
   end)
1 Like

Just add an extra int value and repeat, just with a different datastore.

1 Like

Maybe putting it at “ds2”? Would that help?

1 Like
local ds = game:GetService(“DataStoreService”)
local ds1 = ds:GetDataStore(“CashSaveSystem”)
local ds2 = ds:GetDataStore("KillsSaveSystem") --Or whatever name you want.

game.Players.PlayerAdded:connect(function(player)
local fold = Instance.new(“Folder”, player)
fold.Name = “leaderstats”

local Crowns = Instance.new("IntValue", fold)
Crowns.Name = "Crowns"
Crowns.Value = 0

local Kills = Instance.new("IntValue", fold)
Kills.Name = "Kills "
Kills.Value = 0

Kills.Value = ds2:GetAsync(player.UserId) or 0
ds2:SetAsync(player.UserId, Kills.Value)
Crowns.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, Crowns.Value)
	
Crowns.Changed:connect(function()
	ds1:SetAsync(player.UserId, Crowns.Value)
end) 
Kills.Changed:connect(function()
	ds2:SetAsync(player.UserId, Kills.Value)
end) 

With that script, when I play the game, it completely deletes the “crowns” from the leaderstats. Would you make another script? But would it still be in the same leaderstats?

It deletes the folder of the “SaveCashSystem” and it ignores the “Crowns”