well my script is for a clicking sim and i am trying to save my leadersats!
local ds = game:GetService("DataStoreService"):GetDataStore("LeaderBoardSave")
game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder", player) folder.Name = "leaderstats"
local val = Instance.new("IntValue")
val.Name = "Clicks"
val.Value = 0
val.Parent = player.leaderstats
local val2 = Instance.new("IntValue")
val2.Name = "Rebirths"
val2.Value = 0
val2.Parent = player.leaderstats
local val3 = Instance.new("IntValue")
val3.Name = "Coins"
val3.Value = 0
val3.Parent = player.leaderstats
local val4 = Instance.new("IntValue")
val4.Name = "Gems"
val4.Value = 0
val4.Parent = player.leaderstats
local stats = ds:GetAsync(player.UserId)
if stats ~= nil then
val.Value = stats[1]
val2.Value = stats[2]
val3.Value = stats[3]
val4.Value = stats[4]
else
val.Value = 0
val2.Value = 0
val3.Value = 0
val4.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player) local save = {}
table:insert(save, player.leaderstats.Clicks.Value)
table:insert(save, player.leaderstats.Rebirths.Value)
table:insert(save, player.leaderstats.Coins.Value)
table:insert(save, player.leaderstats.Gems.Value)
ds:SetAsync(player.UserId, save)
end)
game:BindToClose(function() wait(1.25) end)``

1 comment
sorry for the "*" in the first line of code, i didnt mean to put that there