Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Unable to cast array to int64?

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

2 answers

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)

3 comments

0

If this answer helped you, please mark it as correct.

0

it didn't work I got a error HTTP 404 (Forbidden) :(

0

I gives me a error saying HTTP 404 (BadRequest)

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

This discussion is preserved as it was. New answers, comments, and votes are closed.