I have a script inside a button that lets a player play with a certain power only if they have the gamepass. Everything in the script should work perfectly but I get an output error for line 16 saying "Unable to cast value to Object" How can I fix this?
local Menu = game.Players.LocalPlayer.PlayerGui.Menu.Frame
local CurrentQuirk = game.Workspace.CurrentQuirk
local Gamepass = true
local GamepassID = 14988764
local Player = game.Players.LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
if Gamepass == true then
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
Menu.Visible = false
CurrentQuirk = script.Parent.Name
print(CurrentQuirk)
else
MarketplaceService:PromptGamePassPurchase(GamepassID, Player)
end
elseif Gamepass == false then
Menu.Visible = false
CurrentQuirk = script.Parent.Name
print(CurrentQuirk)
end
end)

2 comments
On line 16, the first parameter should be the Player, and the second parameter should be the ID
Thank you so much, problem fixed