Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

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

Answer this question