DataStore2: Is it possible to multiple a data in increment?

Hello Developers,

I was wondering if,
coinStore:Increment(2) = + 2,work.
coinStore:Increment(-2) = - 2,work.
so,
coinStore:Increment(*2) = * 2,must work too, but it doesn’t I just test it.Why?
Can someone help me how multiple data in DataStore2? :thinking:

1 Like

You can use the second parameter of the :UpdateAsync function. For example:


pointsDataStore:UpdateAsync(key, function(value)
	return value * 2
end)

You can also read the data, multiply it, then set it with :GetAsync and :SetAsync.

2 Likes

Increment woundt work with *. Only with -2, it’s a math question. If you do 4 + -2 (inverted number) it’s the same as doing 4 - 2. Just like doing 4 minus -2 == 6. So you can use inverted numbers, but the question as in *, it would Not work. For that you should like he said, get the data, multiply it, then save it.

1 Like

I just did, valueStore:Increment(valueStore)
To *2, it can be value + value. is the same thing.
I think its more easy and better like that.