TextButton Gamepass

Read my post above, it needs to be in startergui

1 Like

The LocalScript must NOT be in the workspace. No matter whether it’s in a Invisible Part or not.

I do not understand what you mean, it is not linked to a GUI.

Those textboxs are in a surfacegui, right?

They were at first but I removed the text.

So right now what are they in?(30 chars)


1 Like

Thats explains why it isn’t working.

Prompting a purchase is only available on the client. Meaning Scripts cannot do this but LocalScripts can.
Replace the Script with a LocalScript and remove the plr parameter in the function. Also put all the LocalScripts into somewhere they can be activated. (LocalScripts in workspace don’t work)

PromptPurchase can work on the Server side.

As I and many people have explained, UI buttons can’t detect any input in the workspace, which is why you need to have a SurfaceGui inside of your StarterGui and adornee it to the part. After what I show you, use the script that I and others have provided before and you should be good.

You should have it somewhat like this, even though you have extra frame it’s the same concept.


Then make sure that the adornee property is set to the part.



It works on both server and client. But its better practice to do it on the client.

I’m not going to directy spoonfeed this to you, but here.
Before scripting, let’s put an IntValue as a child of each button that’s called “GamepassId,” and have its value set to the GamepassId of each button. This will help us prompt the actual gamepass purchase.
Let’s first define MarketplaceService as a variable, define the part with the advertising signs on it, and then define the LocalPlayer like this:

local MarketplaceService = game:GetService(“MarketplaceService”)
local YourPart = workspace:WaitForChild(“YourPartNameHere”)
local LocalPlayer = game.Players.LocalPlayer

After this, you can define the buttons as a variable, or you can use a for i,v loop to get it set up “automatically.”

(I don’t know what happened with my identation below, sorry about that).

for i,v in pairs (YourPart:GetDescendants()) do–Loops through the descendants of the part
if v:IsA(“ImageButton”) then–Checks if the descendant is an ImageButton
MarketplaceService:PromptGamePassPurchase(LocalPlayer,v.GamepassId.Value)–Prompts the purchase, this is where the IntValue comes in

Again, I’m sorry about the indentation, I don’t know what happened.
This is very basic, but this is where I’ll leave it for you.

Anyways, you can do some pretty cool stuff adding onto this, by setting the text from “BUY NOW” to “OWNED” or something similar by checking if the LocalPlayer owns the gamepass.

You should check MarketplaceService out here:

Hope this helped!

1 Like

I had trouble doing this but I have fixed mine and here is my code

local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local Id = 0000000 -- Your Game pass Id here

		mps:PromptPurchase(plr, Id)

Also, you want to put your SurfaceGui in StarterGui

And then, in properties for the Gui, make the Adornee the part you want the button to be on.

Hope this helped! :slight_smile:


This comes up with

MarketplaceService:PromptGamePassPurchase() player should be of type Player

so i’m not sure if this is very accurate

ok wow i just realised it’s 4 years old