local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local save1 = plr.leaderstats.dollar
local save2 = plr.hasjoinedbefore
local GetSaved = ds:GetAsync(plrkey)
if GetSaved then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
else
local NumberForSaving = {save1.Value, save2.Value}
ds:GetAsync(plrkey, NumberForSaving)
end
end)
game:BindToClose(function()
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync("id_"..plr.userId, {plr.leaderstats.dollar.Value, plr.hasjoinedbefore.Value})
end)
end)
and the end where it has bindtoclose isn’t working im probably doing this wrong so i need help please a thank