My script isn’t even printing “test” when the prompted to. The only thing that pops up the script is:
So I know that the script is working, just not sure what might be interfering.
Server:
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
productFunctions[1182939076] = function(receipt, player)
print("test")
local SciBucks = player:FindFirstChild("leaderstats"):FindFirstChild("SciBucks")
if SciBucks then
SciBucks.Value = SciBucks.Value + 25
return true
end
end
productFunctions[1182939225] = function(receipt, player)
print("test")
local SciBucks = player:FindFirstChild("leaderstats"):FindFirstChild("SciBucks")
if SciBucks then
SciBucks.Value = SciBucks.Value + 50
return true
end
end
local function processReceipt(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
local purchased = false
local success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
print("\nProductId:", receiptInfo.ProductId)
print("\nPlayer:", player)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, errorMessage = pcall(function()
purchaseHistoryStore:SetAsync(playerProductKey, true)
end)
if not success then
error("Cannot save purchase data: " .. errorMessage)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
One of the Client (The other is identical with a different id):
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(player, 1182939225) -- 50
end)