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

Gamepass buy brick isn't working?

Title

gamepassid = 931935266
local player = game.Players.LocalPlayer
local marketplaceService = game:GetService("MarketplaceService")

function onClicked(playerWhoClicked)
	marketplaceService:PromptPurchase(player, gamepassid)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Your problem is that this is a LocalScript running on the server.

You defined the parameter "playerWhoClicked", yet tried to use the "player" variable. You cannot index the localplayer from the server.

Simply use the playerWhoClicked variable. And make sure this is a Script object.

local marketplaceService = game:GetService("MarketplaceService")
local gamepassid = 931935266

function onClicked(playerWhoClicked)
	marketplaceService:PromptPurchase(playerWhoClicked, gamepassid)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

0

hmm. still doesn't show the gamepass prompt

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