TextButton isn't prompting game pass purchase

  1. What do you want to achieve? Keep it simple and clear!

Hello, I want a gamepass to be on a surface along with a TextButton.

  1. What is the issue? Include screenshots / videos if possible!

I have tried clicking on the TextButton but the “PromptGamePassPurchase” isn’t showing up even tho I already defined it.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I look up on the Devhub and try google search it and I couldn’t find it.

local ID = 16908254
local player = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")
local Click = workspace.Part.SurfaceGui.Click
local ClickDetector = script.Parent

if ClickDetector then
	MPS:PromptGamePassPurchase(ID, player)
	Click.Text = "Bought"
	Click.BackgroundColor3.G  = Color3.fromRGB(255, 0, 0)
end

I really hope someone could help me with this.

Thanks!

Fix This Line:
if ClickDetector.MouseClick then.

Read This. It helps you a lot:

1 Like

player comes before ID, Also you don’t have the event set up properly. Are you trying to make a Clickdetector do it or a Textbutton?

1 Like

I am trying to make a Textbutton to prompt the purchase of gamepass on a Part.

Put the SurfaceGui in StarterGui and change the Adornee to the part you want to dispaly it on and use this code in a localscript i nthe textbutton

local ID = 16908254
local player = game.Players.LocalPlayer
local MPS = game:GetService("MarketplaceService")
local Click = script.Parent

Click.MouseButton1Click:Connect(function()
	MPS:PromptGamePassPurchase(player,ID)
	Click.Text = "Bought"
	Click.BackgroundColor3  = Color3.fromRGB(255, 0, 0)
end)

Bro, I’m speechless I feel so dum idk why my code doesn’t work but yours did :confused:

1 Like

Your code was checking a Clickdetector exists and if it does, prompt the purchase to an ID. PromptGamePassPurchase has player instance and then the ID. All you needed was the use MouseButton1Click and prompt the player correctly

If you have anymore issues don’tbe afraid t omake another psot!

Alright, Thanks tho! I really appreciate all the help you given to me D:

1 Like