[BEGINNER] [OS] PopulateGamePass - Add new gamepass without aching your hands

image
Screenshot of PopulateGamePass with id 1

Why PopulateGamePass

Do you find cloning a new button for a GamePass labor-intensive? If so, why not ask the machine to do it for you?

Advantages of relying on machines:

  • It’s no longer labor-intensive :smiley:
  • Need to add a new GamePass? Ask the machine to add it!
  • The GamePass status relies on the GamePass, so if you made it off-sale, it will be off-sale and if you changed the title, the title in-game will be changed as well!

So, how does PopulateGamePass works?

PopulateGamePass relies on a method from MarketplaceService called GetProductInfo, which will get the asset info if you have the ID of it.

Here’s a brief mindset of PopulateGamePass:

  1. You call the function with the player, the location to put the button in, and all the GamePass IDs.
  2. The function will go into a loop of the table.
  3. PCall and get the product info via :GetProductInfo.
  4. Clone the template button.
  5. Configure the button by changing the name, title, description and price based on the result returned by :GetProductInfo.
  6. Connect clicked event with InputEnded, where when the user clicked on it, it will prompt player a GamePass purchase
  7. Put it to the location you defined.

I want to configure the template button, how?

Simply put the new template inside the module and name it "Button". Do note you might have to touch with the code! (Programming knowledge needed)

Seems cool, how can I get it?

You can get it here:

PopulateGamePass.rbxm (7.3 KB)

Syntaxes

    PopulateGamePass(instance Player, instance Target, table {GamePassId})

Example:

    PopulateGamePass(game:GetService("Players").LocalPlayer, script.Parent, {1, 2, 3, 4})

Notes

This does not come with a sorting function and is not a shop system. To implement a shop system, do use UIListLayout
16 Likes

To improve upon this I would suggest making a plugin that you type the gamepass or product ID in then you get the GUI and script made for you, but great job!

This system relies on the GamePass, plugin wouldn’t be a smart way: image

1 Like

I meant as like an add-on the plugin also creates the scripts for it, therefor it can update.