Hello! I've made a gui to purchase a gamepass. The button is scripted with the following code:
local plr = game.Players.LocalPlayer
local button = script.Parent
local MarketplaceService = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(plr, 3312863)
end)
It fails, and the output text is: MarketplaceService:PromptGamePassPurchase() player should be of type Player, but is of type nil Any help?

1 comment
Is this a server script or a localscript? You can only use localplayer in a localscript.