Hi! I need help on how to process the receipt after a player buys a DevProduct.
I know there are better/easier ways of doing this, but this is actually one of my first systems that I tried to make myself with little help…
So everything here works, but there is a part that only works in Studio Solo Play.
I will explain in comments what everything does.
This ServerScript runs after a LocalScript inside a Button fires the Remote Event (this works both in Studio and In-Game):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassPromptEvent = ReplicatedStorage.Events.GamepassPromptEvent
local devproductPromptEvent = ReplicatedStorage.Events.DevProductPromptEvent
gamepassPromptEvent.OnServerEvent:Connect(function(player, id) --Fires if player clicks on a button to buy a gamepass
MarketplaceService:PromptGamePassPurchase(player, id) --Prompts GamePass
print("Gamepass Prompted!")
end)
devproductPromptEvent.OnServerEvent:Connect(function(player, id) --Fires if player clicks on a button to buy a devproduct
MarketplaceService:PromptProductPurchase(player, id) --Prompts DevProduct
print("DevProduct Prompted!")
end)
After the player closes the purchase prompt this ServerScript runs (this works both in Studio and In-Game):
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local purchaseFinishedEvent = ReplicatedStorage.Events:WaitForChild("PurchaseFinishedEvent")
local purchaseUnfinishedEvent = ReplicatedStorage.Events:WaitForChild("PurchaseUnfinishedEvent")
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, assetId, isPurchased) --After player closes the game pass prompt do
if isPurchased then --If player bought the game pass do
purchaseFinishedEvent:FireClient(game.Players:GetPlayerByUserId(player)) --Fire localscript that makes a message appear
print(game.Players:GetPlayerByUserId(player).Name.." bought GamePass with AssetID: "..assetId)
else --If player didn't buy the game pass do
purchaseUnfinishedEvent:FireClient(game.Players:GetPlayerByUserId(player)) --Fire localscript that makes a message appear
print(game.Players:GetPlayerByUserId(player).Name.." didn't buy GamePass with AssetID: "..assetId)
end
end)
MarketplaceService.PromptProductPurchaseFinished:Connect(function(player, assetId, isPurchased) --After player closes the devproduct prompt do
if isPurchased then --If player bought the devproduct do
purchaseFinishedEvent:FireClient(game.Players:GetPlayerByUserId(player)) --Fire localscript that makes a message appear
print(game.Players:GetPlayerByUserId(player).Name.." bought DevProduct with AssetID: "..assetId)
else --If player didn't buy the devproduct do
purchaseUnfinishedEvent:FireClient(game.Players:GetPlayerByUserId(player)) --Fire localscript that makes a message appear
print(game.Players:GetPlayerByUserId(player).Name.." didn't buy DevProduct with AssetID: "..assetId)
end
end)
Everything until here works perfectly fine!
This next ServerScript only works perfectly on Studio Solo Play/Test. It doesn’t do nothing in Studio Team Test or In-Game.
I know this because the function only prints and the values only change when I’m in Studio Solo Play…
local marketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local flingevent = ReplicatedStorage.Events.FlingEvent
marketPlaceService.ProcessReceipt = function(receiptInfo)
print("test")
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if receiptInfo.ProductId == ~DevProductIdHere~ then
player.values.Skips.Value = player.values.Skips.Value + 1
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == ~DevProductIdHere~ then
player.values.Skips.Value = player.values.Skips.Value + 3
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == ~DevProductIdHere~ then
player.values.Skips.Value = player.values.Skips.Value + 5
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif receiptInfo.ProductId == ~DevProductIdHere~ then
flingevent:Fire()
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Can someone help me?