Hello!
So I know that Roblox updated how GamePassService works, and I've been using one of their teleport models for ages, that worked just fine until the latest update. I thought I'd fixed my code here with the new terms, but I'm getting this error for Line 37 "Unable to cast string to int64" What is this? I've never seen this, and am unsure how to correct it.
Script below:
-------------------- --| 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 = "rbxassetid://879190380" local ExitLocationObject = WaitForChild(script, 'ExitLocation') 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 game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, GamePassIdObject) 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(ExitLocationObject.Value) 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
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, GamePassIdObject) then
MarketplaceService:UserOwnsGamePassAsync()
takes two arguments, firstly, the player's User ID, and secondly an integer of the game pass ID to test ownership for.
http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/UserOwnsGamePassAsync
Also:
local GamePassIdObject = "rbxassetid://879190380"
You may be looking for this instead:
local GamePassIdObject = 879190380