✓ 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 =
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 =
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
Thank you so much!
No problem!
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?
Sure!
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?
oops my bad
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
I hope it works but your welcome!
it should be able to work
Hello. I think there is a problem with the "processReceipt". An orange line appears under the processReceipt code. Am I doing something wrong?
Hello?
I think you are doing something wrong. Try this script now
Okay thank you I will test it
It works! Finnaly! Thank you so much for your help :D
Yay!