I have a button, right by the VIP door in my game and I want you to be able to buy the gamepass, by pressing the button. Heres my script. The error is it saying "Unable to cast value to Object".
local CLICK_BLOCK = script.Parent local ITEM_ID = 5347758 local Click = Instance.new("ClickDetector") Click.Parent = CLICK_BLOCK Click.MouseClick:Connect(function(p) game:GetService("MarketplaceService"):PromptGamePassPurchase(p.UserId,ITEM_ID) end)
PromptGamePassPurchase
has 2 arguements. The first is a player
, which is an Instance
. The 2nd is the gamePassId
. You are passing the player's userid, not the player.
local CLICK_BLOCK = script.Parent local ITEM_ID = 5347758 local Click = Instance.new("ClickDetector") Click.Parent = CLICK_BLOCK Click.MouseClick:Connect(function(p) game:GetService("MarketplaceService"):PromptGamePassPurchase(p,ITEM_ID) end)