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

Not able to prompt gamepass purchase?

I set it up so that when you click a textbutton, it prompts you to buy a gamepass. Here's the code:

local plr = game.Players.LocalPlayer
local gpId = 1011985603
script.Parent.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, gpId)
end)

When the game is running and I click the button, instead of asking me to buy the gamepass, it says "Your purchase failed because something went wrong. Your account has not been charged. Please try again later." In the output it says "PurchasePromptScript: getProductInfo failed because MarketplaceService:getProductInfo() failed because HTTP 0 (HTTP 400 (HTTP/1.1 400 BadRequest)) Make sure a valid ID was specified"

This was done in a LocalScript inside the button. I tried this with various gamepass id's from very popular games and it still won't work. Any help?

6 comments

0

The error is self explanatory. Check the ID to see if it has any typos.

0

USE A CODE BLOCK or we will not want to help you. Error means you are not passing the ID of a gamepass

0

I checked the ID and it was the same as in the URL

0

Humm... Just checked the ID and it seems to be valid. Im stumped

0

do PromptPurchase, maybe that will work

0

Not sure why, but that worked. Thank you so much!

2 answers

Use PromptPurchase instead of PromptGamePassPurchase

Hi, You should use :PromptPurchase() Instead Of :PromptGamePassPurchase()

I have a fixed script below:

local plr = game.Players.LocalPlayer
local gpId = 1011985603
script.Parent.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptPurchase(plr, gpId)
end)
-- Fixed By UltraAviation

I hope I helped :)

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