Your purchase failed because something went wrong error

I am trying to make a Rainbow Carpet Gui that when clicked, it should give the option to purchase the gamepass. However all I’m getting is “Your purchase failed because something went wrong”.

Here's the Local Script

local MarketplaceService = game:GetService(“MarketplaceService”)
local gamepassID = 17341277222 – Make this number your Gamepass ID

script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, 17341277222)
end)

A screenshot too in case needed.

Please help!!!

3 Likes

Try publishing the place and test it by pressing play on the Roblox website if this is a 3rd party game pass you have to enable it on game settings.

I did play it on the Roblox app in my phone, through a different account to test the gamepasses. Did not work too. And it’s a gamepass from the game, it’s not 3rd party one

1 Like

Try giving it a pcall. So that it doesn’t error.

1 Like

Also are you sure its the correct gamepassid and did you create/publish your gamepass?

Yes it’s the correct gamepass ID. I clicked the “copy ID” in the gamepass page on Roblox Create page. And yes it’s published, for sale at 1 robux (a temporary price just to see if it all works).

What is a pcall and where do I do that?

let me show you give me a second.

local success, errormessage = pcall(function()
marketplaceservice:PromptGamePassPurchase(game.Players.LocalPlayer, gamepassID)
end)
if success then
print("Success")
else
marketplaceservice:PromptGamePassPurchase(game.Players.LocalPlayer, gamepassID)
warn(errormessage)
end

Pcalls just stop your script from breaking if sometimes a line of code fails and errors, sometimes prompt gamepass purchase does fail. That’s why I said use a pcall. Just wrap your promptgamepasspurcahse in this pcall stuff.

1 Like

Oh alright. Where do I paste it? in the script beginning, middle or end?

Just in the mousebuttonclick event you made. Wrap that promptgamepasspurchase thing in that pcall I guess. Also try publishing the game if this doesn’t work. Oh wait you did publish, rip.

Here, i did it like this, is it right?

Uh just get rid of the line which isn’t wrapped in a pcall because that would error if it does fail. Basically the promptgamepasspurchase line above local success thingy, that would error. So delete it.

A message very similar to this also happens when Roblox is down or a particular service is down trying again later might actually help

Did it. And it still says error

If this somehow doesn’t work by the way and it still fails then try to maybe wait for 3-5 seconds before prompting, that might do something.

I’ve been having this problem for loads of days. I think 1 week. I just posted about it here now because I want to release the game

Oh then maybe get rid of the promptgamepasspurchase line in the else statement I put.

AND if this doesn’t work then you know wait a bit before prompting the gamepass purchase.

Got rid of it, waited a bit and still says error. Sorry if I’m too bad at this, it’s been like 3 years since I don’t make roblox games