I've been working a tower defense game in Roblox, and I have been trying to add a teleport system, but I get the error (unable to cast array to int64) in the output. The script is to reserve the server, and teleport the players to that private server.
Here's the code:
local MapCollection = {4895754098} local MapID = MapCollection function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local access = game:GetService("TeleportService"):ReserveServer(MapID) game:GetService("TeleportService"):TeleportToPrivateServer(MapID,access,{player}) end script.Parent.Touched:connect(onTouched)
I would like a reply so I can fix the script as soon as possible.
Thanks, notreallysupernova
The first parameter of TeleportService:TeleportToPrivateServer() and TeleportService:ReserveServer() is a number. You are giving a table.
local MapCollection = 4895754098 local MapID = MapCollection function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local access = game:GetService("TeleportService"):ReserveServer(MapID) game:GetService("TeleportService"):TeleportToPrivateServer(MapID,access,{player}) end script.Parent.Touched:connect(onTouched)
Your variable MapID
is incorrect. You are referencing the entire array (MapCollection) while in your usecase to get the place id, you need to reference a specific index inside the array.
Try this:
local MapID = MapCollection[1] print(MapID) -- Output: -- 4895754098