Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a surfaceGUI button popup a gamepass?

Asked by 5 years ago

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)
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. User#20279 0 — 5y
0
Thanks, I couldn't have figured that out. Can you make an answer so I can accept it? Noonekirby 162 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
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. Canyon620_YT 5 — 5y
0
What’s the difference between using a variable and a number value in this situation...? User#20279 0 — 5y
0
Its easier to change a number value Canyon620_YT 5 — 4y
Ad

Answer this question