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
- 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:
- You call the function with the player, the location to put the button in, and all the GamePass IDs.
- The function will go into a loop of the table.
- PCall and get the product info via :GetProductInfo.
- Clone the template button.
- Configure the button by changing the name, title, description and price based on the result returned by :GetProductInfo.
- Connect clicked event with InputEnded, where when the user clicked on it, it will prompt player a GamePass purchase
- 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})