i have been creating developer products that when bought give an item it worked perfectly before, but now when bought it gives me this error and does not give the item. here was my script `
local marketService = game:GetService(“MarketplaceService”)
local dsService = game:GetService(“DataStoreService”)
local purchaseRecordsDataStore = dsService:GetDataStore(“PurchaseRecordsDataStore”)
local purchaseIds = {}
function getCoinAmount(productId)
-- Return correct amount
if productId == 1189748760 then
return 1000
elseif productId == 1189748929 then
return 2200
elseif productId == 1189749123 then
return 5400
elseif productId == 1189749586 then
return 16000
elseif productId == 1189749804 then
return 33400
elseif productId == 1189750014 then
return 68000
end
end
function addToInvFolder(invFolder, item)
-- Get folder
local folder = invFolder:FindFirstChild(item.Parent.Name)
-- Check if already there
local exists = nil
for _, i in pairs(folder:GetChildren()) do
if i.Name == item.Name then
exists = i
break
end
end
if exists == nil then
-- Create new value
local val = Instance.new("IntValue", folder)
val.Name = item.Name
val.Value = 1
else
-- Increment value
exists.Value = exists.Value + 1
end
end
marketService.ProcessReceipt = function(receiptInfo)
-- Get information
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
local productId = receiptInfo.ProductId
-- Get the player's purchase ids
local plrIds = purchaseIds[tostring(plr.UserId)]
-- Check if this is a duplicate attempt
local okay = true
for _, i in pairs(plrIds) do
if i == receiptInfo.PurchaseId then
print("blocked")
okay = false
break
end
end
if not okay then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Save attempt
table.insert(plrIds, receiptInfo.PurchaseId)
-- Check what product
if productId == 1209808345 then
-- Add items to inventory
local inv = plr.Inventory:clone()
local oldInv = inv:clone()
addToInvFolder(inv, game.ReplicatedStorage.KnifeSkins:FindFirstChild("Steampunk Slasher"))
-- Save inventory
local tempInv = plr.Inventory
inv.Parent = plr
tempInv:destroy()
local saveResult = game.ServerScriptService.DataManager.SaveInventory:Invoke(plr, inv)
if saveResult == false then
local tempInv = plr.Inventory
oldInv.Parent = plr
tempInv:destroy()
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Attempt to record the transaction (if it doesn't, oh well)
pcall(function()
purchaseRecordsDataStore:IncrementAsync(plr.UserId .. "_" .. productId, 1)
end)
--
-- Refresh inventory displays
game.ReplicatedStorage.Interactions.Client.RefreshInventoryDisplays:FireClient(plr)
game.ReplicatedStorage.Interactions.Client.ShowChatMessage:FireClient(plr, nil, "You have received Steampunk Slasher.", Color3.fromRGB(255, 219, 11))
-- Print log
print("LOG: " .. plr.Name .. " purchased product " .. productId .. " and received the current item pack!")
elseif productId == 1208663463 then
-- Add items to inventory
local inv = plr.Inventory:clone()
local oldInv = inv:clone()
addToInvFolder(inv, game.ReplicatedStorage.KnifeSkins:FindFirstChild("Time Keeper"))
-- Save inventory
local tempInv = plr.Inventory
inv.Parent = plr
tempInv:destroy()
local saveResult = game.ServerScriptService.DataManager.SaveInventory:Invoke(plr, inv)
if saveResult == false then
local tempInv = plr.Inventory
oldInv.Parent = plr
tempInv:destroy()
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Attempt to record the transaction (if it doesn't, oh well)
pcall(function()
purchaseRecordsDataStore:IncrementAsync(plr.UserId .. "_" .. productId, 1)
end)
--
-- Refresh inventory displays
game.ReplicatedStorage.Interactions.Client.RefreshInventoryDisplays:FireClient(plr)
game.ReplicatedStorage.Interactions.Client.ShowChatMessage:FireClient(plr, nil, "You have received Time Keeper.", Color3.fromRGB(255, 219, 11))
-- Print log
print("LOG: " .. plr.Name .. " purchased product " .. productId .. " and received the current item pack!")
elseif productId == 1209807607 then
-- Add items to inventory
local inv = plr.Inventory:clone()
local oldInv = inv:clone()
addToInvFolder(inv, game.ReplicatedStorage.KnifeSkins:WaitForChild("Steampunk Slasher"))
addToInvFolder(inv, game.ReplicatedStorage.KnifeSkins:WaitForChild("Time Keeper"))
addToInvFolder(inv, game.ReplicatedStorage.Pets:WaitForChild("Mechanic Bird"))
-- Save inventory
local tempInv = plr.Inventory
inv.Parent = plr
tempInv:destroy()
local saveResult = game.ServerScriptService.DataManager.SaveInventory:Invoke(plr, inv)
if saveResult == false then
local tempInv = plr.Inventory
oldInv.Parent = plr
tempInv:destroy()
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Attempt to record the transaction (if it doesn't, oh well)
pcall(function()
purchaseRecordsDataStore:IncrementAsync(plr.UserId .. "_" .. productId, 1)
end)
--
-- Refresh inventory displays
game.ReplicatedStorage.Interactions.Client.RefreshInventoryDisplays:FireClient(plr)
game.ReplicatedStorage.Interactions.Client.ShowChatMessage:FireClient(plr, nil, "You have received Steampunk Pack.", Color3.fromRGB(255, 219, 11))
-- Print log
print("LOG: " .. plr.Name .. " purchased product " .. productId .. " and received the current item pack!")
elseif productId == 1166863694 then
-- Add items to inventory
local inv = plr.Inventory:clone()
local oldInv = inv:clone()
addToInvFolder(inv, game.ReplicatedStorage.KnifeSkins:FindFirstChild("Dusekkar"))
addToInvFolder(inv, game.ReplicatedStorage.Effects:FindFirstChild("Dusk"))
addToInvFolder(inv, game.ReplicatedStorage.Pets:FindFirstChild("Dusekkar's Beast"))
-- Save inventory
local tempInv = plr.Inventory
inv.Parent = plr
tempInv:destroy()
local saveResult = game.ServerScriptService.DataManager.SaveInventory:Invoke(plr, inv)
if saveResult == false then
local tempInv = plr.Inventory
oldInv.Parent = plr
tempInv:destroy()
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Attempt to record the transaction (if it doesn't, oh well)
pcall(function()
purchaseRecordsDataStore:IncrementAsync(plr.UserId .. "_" .. productId, 1)
end)
--
-- Refresh inventory displays
game.ReplicatedStorage.Interactions.Client.RefreshInventoryDisplays:FireClient(plr)
game.ReplicatedStorage.Interactions.Client.ShowChatMessage:FireClient(plr, nil, "You have received Dusekar Pack.", Color3.fromRGB(255, 219, 11))
-- Print log
print("LOG: " .. plr.Name .. " purchased product " .. productId .. " and received the current item pack!")
else
-- Get coin amounts
local coinAmt = getCoinAmount(productId)
local stats = plr.Stats:clone()
-- Play effect
game.ReplicatedStorage.Interactions.Client.BoughtCoinsEffect:FireClient(plr, coinAmt)
-- Give the player his coins
plr.Stats.Coins.Value = plr.Stats.Coins.Value + coinAmt
stats.Coins.Value = stats.Coins.Value + coinAmt
local saveResult = game.ServerScriptService.DataManager.SaveStats:Invoke(plr, stats)
if saveResult == false then
plr.Stats.Coins.Value = plr.Stats.Coins.Value - coinAmt
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- Attempt to record the transaction (if it doesn't, oh well)
pcall(function()
purchaseRecordsDataStore:IncrementAsync(plr.UserId .. "_" .. productId, 1)
end)
-- Print log
print("LOG: " .. plr.Name .. " purchased product " .. productId .. " and received " .. coinAmt .. " coins!")
end
-- Return a success
return Enum.ProductPurchaseDecision.PurchaseGranted
end
marketService.PromptGamePassPurchaseFinished:connect(function(plr, gamepassId, purchased)
-- Check if Hunter pass
if gamepassId == 16483342 and purchased then
-- Update value
plr.Stats.IsHunter.Value = true
game.ServerScriptService.Functions.RedeemHunterItems:Fire(plr)
-- Update player lists
game.ReplicatedStorage.Interactions.Client.RefreshPlayerList:FireAllClients()
--elseif gamepassId == 10238054 and purchased then
-- Update value
--plr.Stats.HasXPBoost.Value = true
elseif gamepassId == 16482552 and purchased then
-- Update value
plr.Stats.OwnsRadio.Value = true
-- Update character
if plr.Character ~= nil and plr.Character:FindFirstChild("UpperTorso") then
plr.Character:WaitForChild("LoadCosmetics"):Fire()
end
end
end)
game.Players.PlayerAdded:connect(function(plr)
-- Add to records
purchaseIds[tostring(plr.UserId)] = {}
end)
game.Players.PlayerRemoving:connect(function(plr)
-- Remove from records
local newTable = {}
for k, v in pairs(purchaseIds) do
if k ~= tostring(plr.UserId) then
newTable[k] = v
end
end
-- Set new table
purchaseIds = newTable
end)
`