this script works perfectly both on roblox studio or public servers, it stores that Data, but in the output i get this, why?

the output says: Script 'ServerScriptService.Datastore', Line 8

local dataStore = game:GetService("DataStoreService"):GetDataStore("SaveData") 
game.Players.PlayerAdded:Connect(function(plr)
    wait() 
    local plrid =  "id_"..plr.userId 
    local save1 = plr.leaderstats.Money 
    local save2 = plr.leaderstats.Wins

    local GetSaved = dataStore:GetAsync(plrid)
    if GetSaved then 
	save1.Value = GetSaved[1] 
	save2.Value = GetSaved[2]
    else
	local NumberForSaving = {save1.Value, save2.Value}
	dataStore:GetAsync(plrid,NumberForSaving) 
    end 
end) 
game.Players.PlayerRemoving:Connect(function(plr)
    dataStore:SetAsync("id_"..plr.userId, {plr.leaderstats.Money.Value, 
 plr.leaderstats.Wins.Value})

end)

also, it was hard to find the ”correct” title :D

2 comments

0

What's the error under that error?

0

Sorry, we can't help unless you provide what error it is. Is it "attempt to index nil", or something like that?