I have a skipstage developer product which I process on the server and it works perfectly fine in studio. But when purchasing in roblox it will not work even though the player buys the product. Does anybody have a solution to this? Here is the code to my server script.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local id = 1704926416
ReplicatedStorage.Events.SkipStage.OnServerEvent:Connect(function(player)
if player.leaderstats.Stage.Value < 30 then
MarketPlaceService:PromptProductPurchase(player, id)
end
end)
MarketPlaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
local Stage = player.leaderstats:FindFirstChild("Stage")
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == id then
Stage.Value += 1
player.Character:Destroy()
task.wait()
player:LoadCharacter()
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
I have tested and looked in the output. No errors I have a new script shortened with some print statements and the print statments never ran. I hope this gives more information.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptInfo.ProductId == 1704926416 then
print("Player Purchased Skip Stage!")
player.leaderstats.Stage.Value += 1
task.wait()
player:LoadCharacter()
return Enum.ProductPurchaseDecision.PurchaseGranted
else
print("Error")
end
end
I also prompt the product purchase on client now. I can still buy but just doesn’t skip unless i’m testing in studio.
Server script is in ServerScriptService. This is a shared game and there is a chance Since I didn’t make gamepasses that the function is being called. I will check otherwise I’ll try your last option although wouldn’t change anything you’d think.
from what i am seeing, the only reason it would not handle product purchases is if the product is for a game not in the same universe. im not entirely sure why it would not be handling the purchases, so the only thing i can suggest to you is print debugging to see what actually runs. try putting a print at the bottom of the script and a print before&after the if not player statement to see what the function may be getting caught on.
Alright so I have tested game and after 50 robux gone on skip stage I realised the donation board my builder put in has a ProcessReceipt. It’s an asset so I cannot see scripts in studio but I have found it in the console. So I assume my script is fine and I just have to remove that Donation board. Thank you very much for your help