so im trying to make a gamepass "door", and for whatever reason im getting the unable to cast value to object error, here is my script, keep in mind I have other local variables above
local hasgamepass = false local function OnTouched(otherPart) if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then local player = PlayersService:GetPlayerFromCharacter(otherPart.Parent) if player and not JustTouched[player] then JustTouched[player] = time() if hasgamepass == false then GamePassService:PromptGamePassPurchase(game.Players.LocalPlayer.UserId, 4795082) end if GamePassService:UserOwnsGamePassAsync(player.userId, script.GamePassId.Value) then TeleportToOtherSide(player.Character, otherPart) local hasgamepass = true end end end end