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
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
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).
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.
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.
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.