Unable to cast value to object - prompting gamepass

Prompt gamepass script:

local MS = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	MS:PromptGamePassPurchase(plr.UserId, 15938856)
end)

Error:
Screenshot (19)

Can someone help me solve this problem?

Note: Correct me if the topic or if something was wrong.

I think the issue is “plr.UserId” - for whatever reason, apparently PromptGamePassPurchase takes a player object and not their UserId.

If it still doesn’t work after changing “plr.UserId” to “plr” - I’d likely need to see more of the output to help. Let me know if that fixes it!

1 Like

Don’t get the player’s user id, instead just get the player instance. The first parameter of the function is the player instance and not the user id

1 Like