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.
1 | local marketplaceService = game:GetService( "MarketplaceService" ) |
2 | local gamepassid = 931935266 |
4 | function onClicked(playerWhoClicked) |
5 | marketplaceService:PromptPurchase(playerWhoClicked, gamepassid) |
8 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |