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

7 comments
Please use code blocks.
use this code i just uppdated it slightly let me make it better as well
And what is this script type? Is it a server script, is it a local script? What line is your error on?
just a normal script, error on line 53 and also how do i use code blocks in this, sorry im new to this site.
What's a normal script?
https://gyazo.com/22157f7f1443854226575179778259dd This is how to format scripts.
rip code block