#Marketplace Issue
1 messages · Page 1 of 1 (latest)
local PoppyseedPackStand = workspace:WaitForChild("PoppyseedPackStand")
local limitText = PoppyseedPackStand:WaitForChild("Title"):WaitForChild("LimitGui"):WaitForChild("LimitText")
local stockProductId = 3403510225
local maxStock = 7000
local stockKey = "PoppyseedStock"
local dataStore = DataStoreService:GetDataStore("GlobalShopStock")
local currentStock = maxStock
local stockLock = false
local CheckCapacity = events:WaitForChild("CheckCapacity")
local UpdateStockEvent = events:WaitForChild("UpdateStockEvent")
local ManualPurchase = events:WaitForChild("ManualPurchase")
local RestockEvent = events:WaitForChild("RestockSeedPack")
local function loadStock()
local success, saved = pcall(function()
return dataStore:GetAsync(stockKey)
end)
if success and type(saved) == "number" then
currentStock = saved
else
currentStock = maxStock
end
end
local function saveStock()
pcall(function()
dataStore:SetAsync(stockKey, currentStock)
end)
end
local function updateStock()
if currentStock > 0 then
limitText.Text = string.format("%d/%d LEFT", currentStock, maxStock)
else
limitText.Text = "SOLD OUT"
end
UpdateStockEvent:FireAllClients(currentStock, maxStock)
end
local function processPurchase()
if stockLock then return false end
stockLock = true
if currentStock > 0 then
currentStock -= 1
updateStock()
saveStock()
stockLock = false
return true
else
stockLock = false
return false
end
end
local function restock()
if stockLock then return false end
stockLock = true
currentStock = maxStock
updateStock()
saveStock()
stockLock = false
end
loadStock()
updateStock()
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then return Enum.ProductPurchaseDecision.NotProcessedYet end
while not data[player.UserId] and player.Parent do
task.wait(0.1)
end
local playerData = data[player.UserId]
if not playerData then return Enum.ProductPurchaseDecision.NotProcessedYet end
if receiptInfo.ProductId == stockProductId then
local bought = processPurchase()
if bought then
pcall(function()
insertPiggy(player, "Mr. P")
insertPiggy(player, "Mrs. P")
end)
local plot = getAssignedPlot(player)
if plot then refreshPlot(plot) end
events.ShowNotification:FireClient(player, "Purchase Success!", "Purchase")
else
events.ShowNotification:FireClient(player, "Out of Stock!", "Error")
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
CheckCapacity.OnServerInvoke = function(player)
return currentStock > 0
end
ManualPurchase.OnServerEvent:Connect(function(player)
if player.Name == "Incidus_RBLX" then
processPurchase()
end
end)
RestockEvent.OnServerEvent:Connect(function(player)
if player.Name == "Incidus_RBLX" then
currentStock = maxStock
updateStock()
saveStock()
end
end)
game:BindToClose(saveStock)
copying grow a garden aint so simple as it seems ey
you didn't mention any issues, but with the power of my mind-reading abilities, your stock isn't updating for new players, it only sends once at the start and never sends the value to the next players who join
Ill check what you said out but the issue is this:
https://streamable.com/s2d3vo
It works in single player but it doesnt work when im in team test
i can't stream video you'll have to explain it using your words
Theres 5 studio mode. When Im in "Test" mode the product works fine. but when Im in "Team Test" mode the dev product does nothing after purchase
Or is this just a studio bug 😕
what is value of data
I did
local data = {}
and when Im loading the data i do
data[player.UserId] = playerData
But its prob too long I cant send it
you can send messages too long discord attaches it as txt
where call loaddata
Players.PlayerAdded:Connect(loadData)
i suggest add prints to see whats running and what is not around processreceipt
Alr
y'know, beginner debugging
Ok this gotta be a studio bug 💀