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)

2 comments

0

are you trying to load in a players stats? or save?

0

I'm trying to save AND load when the player enters.