Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Unable to cast array to int64?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)

0
If this answer helped you, please mark it as correct. EncapsuIation 450 — 4y
0
it didn't work I got a error HTTP 404 (Forbidden) :( coreyhsGames 5 — 4y
0
I gives me a error saying HTTP 404 (BadRequest) coreyhsGames 5 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question