"Unable to cast value to Object"?

I’m making a GUI for my game so you can buy certain passes or products, using a simple script.

local mps = game:GetService("MarketplaceService")
local lp = game.Players.LocalPlayer
local btn = script.Parent

btn.MouseButton1Click:Connect(function()
	mps:PromptGamePassPurchase(lp.UserId,12437336)
end)

It just errors “Unable to cast value to object”

MarketplaceService:PromptGamePassPurchase takes a player instance, not their user ID. You may have gotten this confused with MarketplaceService:UserOwnsGamePassAsync which does take in a user ID.

1 Like