Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Gamepass buy brick isn't working?

Asked by 7 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

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)
0
hmm. still doesn't show the gamepass prompt ayeayeCommsta 24 — 7y
Ad

Answer this question