I’ve looked around and not found any help with my problem. In short, I need to know the most effective way to detect if a player is actively purchasing a product / gamepass:
Why? My game uses keybinds to open & close GUIs. On a gamepad,
Enum.KeyCode.ButtonB is used to close GUIs. The problem is that this is the same button which closes product prompts, so if you back out of a purchase it will close the whole GUI altogether.
Of course the easiest solution would be to use a different keybind, but
B is the go-to when closing prompts, and would be typical of me to not use it because I didn’t try any other methods.
You can store a boolean variable for each player stating if they have an opened purchase prompt with the default value being
nil. When a purchase is prompted, you can set this variable to
true and wait for the purchase to be over, with functions such as
MarketplaceService.PromptGamePassPurchaseFinished:Wait(), and then set it to false again.
I actually thought of this as soon as I posted, but I saw you started to reply and decided to wait as you may have a better method.
Either way, it works.
Here, have a solution
Note for anyone who comes across this problem in the future:
For developer products, you must use PromptProductPurchaseFinished.