Datastore not updating (UpdateAsync)

What I have tried:
Using IncrementAsync.

The Problem: The problem is that when I try to update a value, it stays at the value and doesn’t change.

local service = game:GetService("DataStoreService")

local function handler(player,eggtype)
	local ds = game:GetService("DataStoreService"):GetDataStore("Stats1")
	local store = ds:GetAsync(player.UserId)
	local petInventoryStore = service:GetDataStore("PetInventory")
	local data = {common = 0,
		uncommon = 0,
		rare = 0,
		legendary = 0,
		godly = 0
	}
	local store1 = petInventoryStore:GetAsync(player.UserId)
	if eggtype == "BasicEgg" then
		if store[1] > 999 then
			local success, error = pcall(function()
				store:UpdateAsync(store[1], function(coins)
					local newcoins = coins - 1000
				end)
			end)
			if store1 == nil then
				petInventoryStore:SetAsync(player.UserId, data)
			end
			local rand = math.random(0,100)
			if rand >= 50 then
				print(store1["common"]) -- this always stays at 0 no matter what
				petInventoryStore:UpdateAsync(store1["common"], function(update)
					local newvalue = update + 1
					return newvalue
				end)
				return true
1 Like

You need to return the value of the transform in the transformFunc
so change the update to. And also, it’s a member of DataStore

ds:UpdateAsync(store[1], function(coins)
     coins -= 1000
     return coins;
end)

Can you explain the ‘common’ part? That doesn’t change.

What do you mean when you say common part?

This part, it doesn’t update add one.

What is the value of store1[“common”]?#

Right now, 1 but it will not add another 1.