Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a surfaceGUI button popup a gamepass?

this is my local script:

local productId = 5969738
	local player = game.Players.LocalPlayer
	 
	script.Parent.MouseButton1Click:connect(function()
	 game:GetService("MarketplaceService"):PromptGamePassPurchase(player, productId)
	end)

2 comments

0

Is your GUI in StarterGui? SurfaceGUIs can only be interacted with if they’re in a player’s PlayerGui, which gets its GUIs from StarterGui. Try putting it there and set the Adornee property from the GUI to the part it was attached to.

0

Thanks, I couldn't have figured that out. Can you make an answer so I can accept it?

1 answer

Okay so you need to have a number value for you gamepass id in your text button and your code should look a little like this

local player = game.Players.LocalPlayer
 
local Button = script.Parent:WaitForChild('Product1') -- Your Button
Button.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(player, Button:WaitForChild('GamePassId').Value) 	end)

3 comments

0

Just make sure you change Product1 to your text button and make sure your Number Value is called GamePassId, and also this script goes inside the SURFACEGUI not the TEXTBUTTON.

0

What’s the difference between using a variable and a number value in this situation...?

0

Its easier to change a number value

This discussion is preserved as it was. New answers, comments, and votes are closed.