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

Why won't this script work?

local productId = 322937935
script.Parent.MouseButton1Click:connect(function()
local player =  script.Parent.Parent.Parent.Parent.Parent
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)

This script is meant to have a player buy a gamepass when a GUI TextButton is pressed, but when I press it, it won't work. Can somebody please fix this?

2 comments

0

What kind of script is this and what is it under in the Explorer?

0

It's a normal script and it's supposed to be for a GUI button where when you press it, you can buy something.

1 answer

Possibly because your trying to pop up a prompt to a model? That's my guess. Try this


local productId= 322937935
local player = script.Parent.Parent
function BuyMe()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end

game.StarterGui.(LocationOfYourButtonHere).MouseButton1Click:connect(BuyMe)

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