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

1gamepassid = 931935266
2local player = game.Players.LocalPlayer
3local marketplaceService = game:GetService("MarketplaceService")
4 
5function onClicked(playerWhoClicked)
6    marketplaceService:PromptPurchase(player, gamepassid)
7end
8script.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.

1local marketplaceService = game:GetService("MarketplaceService")
2local gamepassid = 931935266
3 
4function onClicked(playerWhoClicked)
5    marketplaceService:PromptPurchase(playerWhoClicked, gamepassid)
6end
7 
8script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
hmm. still doesn't show the gamepass prompt ayeayeCommsta 24 — 7y
Ad

Answer this question