Script help needed for donation script

Hello, I just finished my first commission and they chose to pay with gamepass method. So I created this script which asks the person if they want to pay 100 robux. I want the script to also check if the payment is successful and change the text to “Successfully payed”

This is the script:

local player = game.Players.LocalPlayer
local PayCommissionId = "Can't share, sorry"

script.Parent.MouseButton1Click:Connect(function()
	game.MarketplaceService:PromptProductPurchase(player, PayCommissionId)
end)

If the ID is needed really then I can share it
2 Likes

This article here may help you out.

local function Purchased(plr, ID, success)
    if success then
        --If successful
    else
        --If not succesfull
    end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)

This code needs to be a server script. In order to communicate with the GUI you need to use Remote Events

1 Like

So should I type this [MarketplaceService.PromptPurchaseFinished]

local player = game.Players.LocalPlayer
local PayCommissionId = "Can't share, sorry"

script.Parent.MouseButton1Click:Connect(function()
	game.MarketplaceService:PromptProductPurchase(player, PayCommissionId)
end)

if MarketplaceService.PromptPurchaseFinished = true then
script.Parent.Text = "Successfully payed"

Is it how you do it?

Actually I am not clear with this gamepass things and stuff

I edited my reply, go check it out

(and no, the modification you made would not work)

Thank yo for the code but the MarketplaceService word and gamepassPurchaseFinished word are giving red lines under them

Should I make a variable or something?

can you please give me a SCREENSHOT of your code

Ok and I was able to figure out for the MarketplaceService.

Alright. let me know if the code works

The payment things works but I tried doing this:

But the script.Parent.Text = line does not work
Although I have 100 robux in my account

Change

MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)

to

MarketplaceService.PromptGamePassPurchaseFinished:Connect(Purchased)

Yep it worked but did not change the text

Before the if success then line can you please add: warn(success)
then run the script and tell me what value prints

Nope not yet:


Sorry had to blur my discord name and the other person’s name

can you please go into “view” and enable output?

1 Like

you know what it’s fine, I’ll tell him to send the default roblox success message

Thanks for the putting the effort for helping me :grinning:

does the PromptGamepasspurchasefinished work for prompting a developer product not a gamepass

Developer Products have to be handled differently than gamepass purchases.

Check out this page here: Developer Products | Roblox Creator Documentation
it explains what you need to do pretty well