I am making a GUI button where if you click it, you will be prompted with a gamepass. If you own it or buy it, it will show a new gui where you can choose a level (my game has free levels and paid access levels).
However, when I create the function, I get:
attempt to index local 'player' (a nil value)
Here is the code:
local debounce = false
local Id = 7985691 --My gamepass id
function onButtonClicked(player)
if debounce == false then
debounce = true
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 7985691) then
script.Parent.Click:Play()
game.Workspace.Sound:Stop()
game.Workspace.Sound2:Play()
script.Parent.Parent.Parent.PremLevelsGUI.Visible = true
script.Parent.Parent.Parent.PremInfo.Visible = true
script.Parent.Visible = false
script.Parent.Parent.House.Visible = false
script.Parent.Parent.HTP.Visible = false
script.Parent.Parent.Parent.Back.Visible = true
debounce = false
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(player, 7985691)
debounce = false
end
end
end
script.Parent.MouseButton1Click:connect(onButtonClicked)
Any help is much appreciated,thanks!

4 comments
i would also like the main code
Okay, it's right here
MouseButton1Click doesn't pass the player as an argument to its callback.
What do i use instead then?