I am making a DataStore so when the player leave the leaderstats save, my problem is: when i rejoin the data don't save this is my script
local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_xd"..plr.userId
local save1 = plr.leaderstats.Money
local save2 = plr.leaderstats.Strength
local save3 = plr.leaderstats.Rebirths
local GS = ds:GetAsync(plrkey)
if GS then
save1.Value = GS[1]
save2.Value = GS[2]
save3.Value = GS[3]
else
local NFS = {save1.Value, save2.Value, save3.Value}
ds:GetAsync(plrkey, NFS)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync("id_xd"..plr.userId, {plr.leaderstats.Money.Value, plr.leaderstats.Strength.Value, plr.leaderstats.Rebirths.Value})
end)
help please!

5 comments
Tip: You should always wrap your functions in pcall.
Have you already made the leaderstats?
yes
You must use a Server-sided Script (commonly called a "regular" script); preferably located in ServerScriptService.
i have it in ServerScriptService