I have made a cash data that saves my data. It works and saves my data, but I also want to make a if a player kills a player they earn gold script in there. I dont know how to do that

Please help me! Here is my script

local DataBaseStore = game:GetService("DataStoreService"):GetDataStore("testing-ds-pixel") local StatSholder = script.Stats

game.Players.PlayerAdded:Connect(function(NewPlayer)

local Key = "Player-ID:" .. NewPlayer.userId local GetSave = DataBaseStore:GetAsync(Key)

local DataBaseFolder = Instance.new("Folder", NewPlayer) DataBaseFolder.Name = "leaderstats" for i, Stats in pairs(StatSholder:GetChildren())do local NewStats = Instance.new(Stats.ClassName) NewStats.Name = Stats.Name NewStats.Value = Stats.Value NewStats.Parent = DataBaseFolder end if GetSave then for i, Stats in pairs(script.Stats:GetChildren())do DataBaseFolder[Stats.Name].Value = GetSave[i] print (i, Stats.Name, Stats.Value) end

else

local StatsToSave = {}

for i, Stats in pairs(DataBaseFolder:GetChildren()) do table.insert(StatsToSave, Stats.Value) print(i, Stats.Name, Stats.Value) end DataBaseStore:SetAsync(Key, StatsToSave) end while wait(30) do local StatsToSave = {}

for i, Stats in pairs(DataBaseFolder:GetChildren()) do table.insert(StatsToSave, Stats.Value) print(i, Stats.Name, Stats.Value) end DataBaseStore:SetAsync(Key, StatsToSave) end game.Players.PlayerRemoving:Connect(function(OldPlayer) local Key = "Player-ID" .. OldPlayer.userId local StatsToSave = {}

for i, Stats in pairs(DataBaseFolder:GetChildren()) do table.insert(StatsToSave, Stats.Value) print(i, Stats.Name, Stats.Value) end DataBaseStore:SetAsync(Key, StatsToSave) end) end)

I added a number value called coins too inside the script.

Please help me!