Is there a way to run code when someone bought a GamePass?

So, I want to make a gamepass system that when a specific gamepass is bought, it automatically works in-game.

I have tried using loops but that could cause problems.

Is there a way to do this?

Yes!
You can use MarketPlaceService.PromptGamePassPurchaseFinished for that.
It basically fires when you finished purchasing and closing the purchase complete window.

More info about that function can be found in the Documentation.

2 Likes

does this also work when a gamepass is purchased on the roblox website?

No it wont since that code runs in the game

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.