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

How to make a gui appear when buying a dev product?

Hello. I'm developing a game but I need help with something. I want to make a gui appear when buying a dev product. It's like a sucessfully bought message or something. I tried to find on youtube but nothing works. I hope I get an answer here.

Regards.

1 answer

✓ Accepted answer

I know this looks like the same script but I just want to see if it works.

Put a LocalScript inside the TextButton:


local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local productID = --Dev product ID  
 
 
script.Parent.MouseButton1Click:Connect(function(promptPurchase)
	local player = Players.LocalPlayer
	MarketplaceService:PromptProductPurchase(player, productID)
end)

Put a ServerScript (Script) inside the TextButton:

local bought = script.Parent.Bought
local MPS = game:GetService("MarketplaceService")
local productID = --Dev product ID again

function processReceipt(receiptInfo)
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	if ReceiptInfo.ProductId == productID then
		bought.Visible = true
		bought.Text = "You have bought a DevProduct!"
	end
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
 
MPS.ProcessReceipt = processReceipt

15 comments

0

Thank you so much!

0

No problem!

0

Oh hey again. I want the gamepass to be bought with a button. So the player should click and then buy the gamepass and then when he buys, the gui appears. Can you show me how that works in code?

0

Sure!

0

Hey! The first part of the script works perfectly. But the function of when the gamepass is bought is not working. I’m probably doing something wrong so where can I find the function of when the gamepass is bought?

0

oops my bad

0

I can’t test the script now but tomorrow I can. I hope it works and anyways thank you so much for your help :D

0

I hope it works but your welcome!

0

it should be able to work

0

Hello. I think there is a problem with the "processReceipt". An orange line appears under the processReceipt code. Am I doing something wrong?

0

Hello?

0

I think you are doing something wrong. Try this script now

0

Okay thank you I will test it

0

It works! Finnaly! Thank you so much for your help :D

0

Yay!

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