How do i cancel a ProductPurchasePrompt

I have this system where it gives the player 15 seconds to purchase a revive and if they don’t then they can’t revive. How ever the purchasePrompt still lingers after 15 seconds meaning players could potentially waste their money…

After scanning the MarketplaceService API Page i have yet to find a way to force cancel it.

I’ve tried returning Enum.ProductPurchaseDecision.NotProcessedYet on MarketplaceService.ProcessReceipt if the 15 seconds were passed but this didn’t help.

Any suggestions?

.

2 Likes

Teleport the player to interrupt the prompt.

1 Like

teleporting didn’t help, i’m curious tho where did you learn that? lol

Guessed. I just guessed lol! I guess it closes ESC menu.

2 Likes

I probably sound dum, but if Its an event, have you tried disconnecting it?

1 Like

I like the idea but it’s a method not an event. Heres what it looks like for future reference

MarketplaceService:PromptProductPurchase(Player, ID)

1 Like

Ah, I see. Thanks for letting me know!

1 Like

I don’t think you physically can. I’ve been a developer for 3 years and I’ve tried this for a timed revive system, but I don’t think you can because it’s a CoreGui. But if you can I will be interested!

(Looks like people are requesting this as seen in this post: Request for Devs to Cancel PromptPurchase - #5 by EmeraldSlash )

A solution is to make it so when you buy it, it checks the time left. If there is time, then they can successfully revive. If they buy it, and the time is up, you save this in a data store for the next time they click the revive button (so they get their revive, but for the next round, and they aren’t prompted with it, if they had an old revive) If that makes sense? Or another solution is that you don’t worry at the time and just hope people don’t buy it. Not the preferred method, but what a lot of developers do.

5 Likes

if this is single player, perhaps you should pause the timer until the player presses cancel or buys it.

Other wise, perhaps save the revive for next time and let the player use it next death

After 15 seconds couldn’t you disable all core gui, then reenable it? Just a guess I am also quite interested in the answer if you do end up finding one.

I don’t think you can and that’s for a good reason. I’ll have to see in studio but you can only disable certain things. Because the CoreGui also contains the menu to leave the game which must always be available.

(Idk myself. I need to be more educated on CoreGui)

1 Like

try implementing your own timer and checking the elapsed time before allowing the player to make a purchase.

example code:

local function promptPlayerToPurchase(player)
    local promptId = "RevivePrompt"
    local purchaseMade = false
    game:GetService("MarketplaceService"):PromptProductPurchase(player, promptId)
    wait(15)
    if not purchaseMade then
        print("Revive purchase not made. Revive functionality disabled.")
    end
end

local player = game.Players.LocalPlayer
promptPlayerToPurchase(player)

You pretty much can’t, it’s not an API (yet) as @OfficialPogCat correctly stated.

1 Like

pause timer if the prompt is up?

No, the OP is asking whether they can cancel a purchase prompt once the timer is up.

im just suggesting a workaround this need

I think the best thing to do is that if there isn’t yet, just add buttons to either go back to the lobby immediately or revive, which brings up the prompt.

I don’t think a Player would try and purchase the Revival last second, otherwise they pretty much had it coming.

This doesn’t solve the problem of allowing me to hide the prompt after 15 seconds, imagine the purchase is made after 15 seconds but the game is already over. They would essentially just lose their money

To anyone looking for a solution: Turns out there’s no real way to do this so i have to work around it

Also great suggestions pogcat, saving the revive for next round might work but players might get upset if they wanted the revive specifically for that round. And i don’t feel okay just leaving it as it is cause ik someone is gonna lose their money lol

I’ve decided to just make a new currency called revives and have players buy that when ever they want. Then they can use it immediately if they have any available.

2 Likes

There is a way to remove all core gui, most people use it for loading screens and such. But it might not be the solution to this problem.