Gamepass / DevProduct Store

Hello, I’m sure whoever reads this understands what I am trying to achieve by the title. To explain to those who don’t: I am trying to create a Game-pass and Developer Product store in my game but I haven’t been able to for the past couple hours even with the help of the DevForum, DevHub & YouTube. None of the sources were specific to my situation. The GUI is all set up but the coding is where I am stuck. I have provided 2 screenshots below: One of the GUI layout in ‘Explorer’ and the second one of the script that I currently have. If you have a solution please do comment and help me out because I’d really like to get this done today. Thank you!
Also, the reason why there’s a “–Gamepass Store” and a “–DevProduct Store” is because I was told they had to be coded separately? I’m not sure…

Screen Shot 2020-09-22 at 5.19.27 PM

2 Likes

What trouble are you having with the coding?

1 Like

I’m just not even sure where to start. I tried different methods and so far I’m still stuck.

1 Like

Are you having trouble with prompting official purchase requests or with your UI?

Since you have your IDs all set up, we can first start with our events to actually initiate the prompt.

To actually prompt a gamepass ID, you can do the following:

local MarketPlace = game:GetService("MarketplaceService")
local Player = game:GetService("Players").LocalPlayer

Button.MouseButton1Click:Connect(function() --Assuming you are using a button to prompt the gamepass. Feel free to  use your own variables and change the event to your liking :)
     MarketPlace:PromptGamePassPurchase(Player, GamepassID)
end)

To prompt a developer product, it’s basically the same script but a different function:

local MarketPlace = game:GetService("MarketplaceService")
local Player = game:GetService("Players").LocalPlayer

Button.MouseButton1Click:Connect(function() --Assuming you are using a button to prompt the gamepass. Feel free to  use your own variables and change the event to your liking :)
     MarketPlace:PromptProductPurchase(Player, GamepassID)
end)

Coding a gamepass or developer product to make it do what you intend is quite easy too. I don’t know how you want the gamepasses to function so I have no say in how you code that, but if you don’t understand how to code gamepasses, give this API a read:

UserOwnsGamePassAsync
Note: This is not an event. This is a function and will return a bool value. Only use it when you want the user to access a gamepass-only event such as going through a door or equipping a weapon. I highly recommend using it on the server side rather than the client to disallow exploiters to access gamepass-only events :slight_smile: