Gamepass button not working

local MarketplaceService = game:GetService(“MarketplaceService”)
local button = script.Parent.Open

button.MouseButton1Down:Connect(function(player)
if not MarketplaceService:UserOwnsGamePassAsync(player.UserId, 5929305) then
MarketplaceService:PromptGamePassPurchase(player, 5929305)
return
end
game.ReplicatedStorage.requestObject:FireServer(48596336)
end)

error: 10:43:10.983 Players.OofMayy.PlayerGui.Main.items.Settings.radio.Script:5: attempt to index number with ‘UserId’ - Server - Script:5

if I use the script without the marketplace, it works normally, it clones the object to the backpack, but with the marketplace it does not clone. If the player has the gamepass, it clones… if you don’t have the gamepass, it popup a msg to buy the gamepass. What could be giving error?

MouseButton1Down does not have a parameter for the player, it only has 2 parameters for the x and y coordinates of the mouse, you have to get the player from somewhere else. Is this in a localscript? What you can do is

local MarketplaceService = game:GetService(“MarketplaceService”)
local button = script.Parent.Open
local player = game.Players.LocalPlayer

button.MouseButton1Down:Connect(function()
    if not MarketplaceService:UserOwnsGamePassAsync(player.UserId, 5929305) then
       MarketplaceService:PromptGamePassPurchase(player, 5929305)
       return
    end
    game.ReplicatedStorage.requestObject:FireServer(48596336)
end)