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