Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[Developer Products]: Can you set another parameter in the `ProcessReceipt` function?[Intermediate]:

I created a developer product system for my game, where there is a bank and you can buy all different products, and i did it with a remote event (necessary)

Everytime the player clicks the gui for any it fires the remote with the exact money you purchased and here is the server script

FOCUS ON LINE 22, and the local script i wrote in here is unecessary to read but i did it anyways

SERVER SCRIPT

local RemoteEvent = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("MarketPlaceRemote").RemoteEvent
local MarketPlaceService = game:GetService("MarketplaceService")

local function ProcessReceipt(receiptInfo, moneygiven)
	
	local Player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not Player then
		-- Player left the game
		
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if Player then
		Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + tonumber(moneygiven)
		
	end
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

RemoteEvent.OnServerEvent:Connect(function(player, moneygiven)
	MarketPlaceService.ProcessReceipt = ProcessReceipt( [[-- Why can't i put the amount of coins that was sent to the thing?? --]] )
end)

LOCAL SCRIPT [You don't need to read this btw!]

-- i already prompted the player above here so yeah..

script.Parent.Parent.ShopFrame.Transaction1.ImageButton.Activated:Connect(function()
	RemoteEvent:FireServer("200")
end)

script.Parent.Parent.ShopFrame.Transaction2.ImageButton.Activated:Connect(function()
	RemoteEvent:FireServer("500")
end)

script.Parent.Parent.ShopFrame.Transaction3.ImageButton.Activated:Connect(function()
	RemoteEvent:FireServer("2000")
end)

script.Parent.Parent.ShopFrame.Transaction4.ImageButton.Activated:Connect(function()
	RemoteEvent:FireServer("10000")
end)

2 answers

✓ Accepted answer

On the client you should be using PromptProductPurchase and it will prompt the specified developer product id. On the server you should set ProcessReceipt as it's own function outside of everything. ProcessReceipt will have a dictionary as a parameter containing all the information on the purchase. You could base the reward the player should get on the product id inside of the receipt. It would end up looking a little something like this on the server.

function MarketPlaceService.ProcessReceipt(Receipt)
	-- do checks
	
	if Receipt.ProductId == 0000000 then
		-- award however much that dev product is worth
	end
end

You should prompt the player to purchase the dev product with the OnServerEvent.

Otherwise, there's no other way to do it.

1 comment

0

Already did so :/

This discussion is preserved as it was. New answers, comments, and votes are closed.