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

Why won't this datastore script work and return the new value?

Asked by 6 years ago

I'm getting this error:

20:30:41.764 - Workspace.PlayerScript:18: attempt to perform arithmetic on local 'newValue' (a table value)

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStorage")


game.Players.PlayerAdded:connect(function(player)
    local key = "user_" .. player.userId

    DataStore:UpdateAsync(key, function(oldValue)
    local newValue = oldValue or 0 
    newValue = newValue + 20
    return newValue
    end)
0
are you trying to load in a players stats? or save? PoePoeCannon 519 — 6y
0
I'm trying to save AND load when the player enters. bigbenbennett 18 — 6y

Answer this question