Unable to cast string to Int64

I recently amended my teleporting lobby module script, but for some reason on line 45 I keep receiving an error:
Unable to cast string to int64

Code:

local reserveSuccess, reserveResult = pcall(function()
		local MapName = DataTable.Map
		if MapName == "Warehouse" then
			serverCode = TeleportService:ReserveServer([ID])
		end
	end)
	if reserveSuccess then
		module.Games[#module.Games+1] = DataTable
		module.UpdateGameListings(Player, DataTable)
		if tostring(FirstThreeLetters) then
			if isPrivate then
				local sendingTable ={
					Password = FirstThreeLetters..RandomNumber,
					AccessCode = serverCode

				}
				local publishSuccess, publishResult = pcall(function()
					MessagingService:PublishAsync(MessagingTopic, sendingTable)
				end)
				if publishSuccess then
					print("Sent The Following Password To Server "..sendingTable.AccessCode..": "..sendingTable.Password)
					TeleportService:TeleportAsync(serverCode, {Player})
				else
					warn(publishResult)
					--Send System Notification Failure Message
				end
			end
		end
	else
		--Prompt System Notification Failure Message
		warn(reserveResult)
		print(reserveResult)
	end

end

Line 45

TeleportService:TeleportAsync(serverCode, {Player})

First argument of TeleportAsync is the placeid to teleport the player(s) to, think you want to use TeleportToPrivateServer in this case as it allows you to specify a Server code i nthe 2nd argument

1 Like

Add one print command before the line 45 and show printed stuff by the command:

print("Code: ", serverCode, " ", "Type: ", typeof(serverCode))

Sorry, I forgot to mark the her solution as true lol. Thanks @EmbatTheHybrid snd @Spiderr12PL

1 Like