local DSService = game:GetService('DataStoreService'):GetDataStore('Pizza')
game.Players.PlayerAdded:connect(function(Player)
local uniquekey = 'id-'..player.userId
local leaderstats = Instance.new('IntValue',player)
local savevalue = Instance.new('IntValue')
leaderstats.Name = 'leaderstats'
savevalue.Parent = leaderstats
savevalue.Name = Kills
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
savevalue.Value = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
DSService:SetAsync(uniquekey,NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local uniquekey = 'id-'..player.userId
local Savetable = {player.leaderstats.Kills.Value}
DSService:SetAsync(uniquekey,Savetable)
end)
I made a script that is supposed to save your kills after you leave the game. This is what the script looks like:
What is wrong? If its something simple please change it and comment it. Thanks.

4 comments
Looks like the script came in a bit buggy, hopefully its understandable
edit it and try to redo it
also savevalue.Name = 'Kills' not kills
Put the script is a code block by pressing the Lua symbol in the edit page and placing the code between the two sets of tildes.