Unable to cast value to object during gamepass prompt

So here is my code located in a local script under a text button

local MarketplaceService = game:GetService("MarketplaceService")
local playerID = game.Players.LocalPlayer.UserId
local gamePassID = 8028917
 
script.Parent.MouseButton1Click:Connect(function(player)
	MarketplaceService:PromptGamePassPurchase(playerID,gamePassID)
end)

And it returns me this error
image

I have no idea what I am doing wrong, I followed the wiki documentation and I am still getting this

1 Like

PromptGamePassPurchase requires a player instance and a game pass ID, not a player ID and game pass ID.

You’ll want to update the corresponding 2 lines as such:

local player = game:GetService("Players").LocalPlayer

MarketplaceService:PromptGamePassPurchase(player, gamePassID)
8 Likes

OHH, I thought it took the player ID as an argument instead of the actual instance, I’m going to see if this works

Ok it has worked. Thank you for the help!