I want to add an oldValue parameter to DataStore2's ":Update()" method. This is what I currently have now:

function DataStore:Update(updateFunc)
	updateFunc(DataStore:Get(0))
	self.value = updateFunc(self.value)
	self:_Update()
end

But it's still nil (printed). Help?

How i print it:

datastore:Update(function(oldVal)
	print(oldVal)
end)

:_Update() function which is used for setting data in DS2 (Used by datastore:Set() and datastore:Update() in DS2):

function DataStore:_Update(dontCallOnUpdate)
	if not dontCallOnUpdate then
		for _,callback in pairs(self.callbacks) do
			callback(self.value, self)
		end
	end

	self.haveValue = true
	self.valueUpdated = true
end

2 comments

0

Can you post full script so I can see what were dealing with here?

1

this part i showed is a part of DS2's MainModule, but when i do datastore:Update(function(oldVal) oldVal is nil