Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Datastore script not working corectly,help?

Asked by
Gigaset39 111
1 year ago

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

0
What's the error under that error? 9mze 193 — 1y
0
Sorry, we can't help unless you provide what error it is. Is it "attempt to index nil", or something like that? LikeableEmmec 470 — 1y

Answer this question