Gamepass script not working

So, I was working on my game Super Spleef and decided to make a gamepass GUI, and so I wrote out the script but when I tested it out, this happened.! 2021-09-26 (2)|690x365

I tried everything to fix it but it did not work. Here is the script I used:

`local productId = 22726185
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
Game:GetService(“MarketplaceService”):PromptPurchase(player, productId)
end)`

Does anyone have a solution?

You cannot use MarketplaceService:PromptPurchase() with a gamepass.
Please use MarketplaceService:PromptGamePassPurchase().

local productId = 22726185
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    game:GetService(“MarketplaceService”):PromptGamePassPurchase(player, productId)
end)
1 Like

Now I am having another issue, when I click it, nothing pops up

robloxapp-20210926-1041595.wmv (755.4 KB)

The quotation marks are the wrong marks. Whoops.
You can find errors like this by pressing F9 in game, or by looking at the Output window in Studio.

local productId = 22726185
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(player, productId)
end)
1 Like

Hey, this script should get you all set:

local productId = 22726185
local player = game:GetService("Players").LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptGamePassPurchase(player, productId)
end)

@parslmonious I recommand using :Connect and not :connect, and to use game:GetService()!

2 Likes

This actually helped me thank you! Also thank you @parsimonious for trying to help me.

1 Like