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

Why won't this datastore work, nothing saves?

Asked by 6 years ago
local DSService = game:GetService('DataStoreService'):GetDataStore('theweirdlolsavedata669')
game.Players.PlayerAdded:connect(function(plr)
    local uniquekey = 'id'..plr.userId
    local stuff = Instance.new("Folder", plr)
    stuff.Name = "stuff"
    local Invun = Instance.new('IntValue', stuff)
    Invun.Name = "Stat1"


    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        Invun.Value = GetSaved[1]
    else
        local NumbersForSaving = {Invun.Value}
        DSService:SetAsync(uniquekey, NumbersForSaving)

    end
end)

game.Players.PlayerRemoving:connect(function(plr)
    local uniquekey = 'id'..plr.userId
    local Savetable = {plr.stuff.Stat1}
    DSService:SetAsync(uniquekey, Savetable)



end)
0
is this a server script? SuperAndresZ_YT 202 — 6y
0
yeah, in the workspace ATestAccount420 31 — 6y

1 answer

Log in to vote
0
Answered by
c0des 207 Moderation Voter
6 years ago

Didn't look too in-depth, however on line 22 you forgot to include ".Value" in the array. If this doesn't solve the problem let me know.

1
Works, thank you ATestAccount420 31 — 6y
Ad

Answer this question