Okay, First of all. Sorry If I offended anyone with my previous post. I Should have included my attempts in solving the problem myself.
I have a really old script which I always used till 2017 when Gamepasses worked different.
--------------------
--| WaitForChild |--
--------------------
-- Waits for parent.child to exist, then returns it
local function WaitForChild(parent, childName)
assert(parent, "ERROR: WaitForChild: parent is nil")
while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
return parent[childName]
end
-----------------
--| Variables |--
-----------------
local GamePassService = Game:GetService('GamePassService')
local PlayersService = Game:GetService('Players')
local DebrisService = Game:GetService('Debris')
local Teleporter = script.Parent
local GamePassIdObject = WaitForChild(script, 'GamePassId')
local ExitPartObject = WaitForChild(script, 'ExitPart')
local JustTouched = {}
-----------------
--| Functions |--
-----------------
-- When a player with the game pass touches the door, teleport them to the other side
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 GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
local character = player.Character
if not character:FindFirstChild('JustTeleported') then
local justTeleported = Instance.new('StringValue')
justTeleported.Name = 'JustTeleported'
DebrisService:AddItem(justTeleported, 0.3)
justTeleported.Parent = character
character:MoveTo(ExitPartObject.Value.Position)
end
end
end
end
end
-- Removes old entries in JustTouched
local function RemoveOldTouches()
for player, touchTime in pairs(JustTouched) do
if time() > touchTime + 0.3 then
JustTouched[player] = nil
end
end
end
--------------------
--| Script Logic |--
--------------------
Teleporter.Touched:connect(OnTouched)
while true do
RemoveOldTouches()
wait(1/30)
end
But It obviously doesnt work any more.
So I changed (16)
local GamePassService = Game:GetService('GamePassService')
to
local MarketPlaceService = Game:GetService('MarketplaceService')
and (37)
if GamePassService:PlayerHasPass(player, GamePassIdObject.Value)
to
if MarketPlaceService:UserOwnsGamePassAsync(player, GamePassIdObject.Value) then
I did not script since 2017 so I am really out of shape. I tried and tried and tried, but Its making me crazy after 5 hours.
With the changes it says: Unable to cast Instance to int64
Please can someone tell me what I am doing wrong?

5 comments
Like I said. In your same post. There is a method called :WaitForChild(). You don’t need a custom function. GamePassIdObject isn’t valid, therefore it can’t cast it.
All methods are now pascal case too.
GamePassIdObject and ExitPartObject are in the script. So it exist.
Right? I am really out of this. How can I makeGamePassIdObject regonize to exist?
UserOwnsGamePassAsync takes the player ID rather than the actual player.