"Unable to cast string to int64" while using Teleport Service

I’m trying to make a matchmaking system, wherein once the player touched the handler part, a intValue is created in a folder representing the matchmaking, upon the max player counter is met, an attempt at teleporting will occur, this is where my problem starts, I don’t really know what’s wrong here. I’ve tried a lot of things, but its too many for me to name.

Problematic Code:

local plrs = { }
				for int, found in game.ServerStorage.Queues:FindFirstChild(v.Name):GetChildren() do
					plrs[int] = found.Value
				end
			


				local tpService = game:GetService("TeleportService")
				local reserveServer = tpService:ReserveServer(15852072777)
				tpService:Teleport(reserveServer,   plrs)

Error:
image

Some things that may help:

I can go in further detail if needed.

What exactly is on line 97 of this problematic script?

tpService:Teleport(reserveServer,   plrs)

Can you please print the reserveServer variable?

Alright, please hold on while I do that.

1 Like

image

You’re using the wrong Teleport method, you need TeleportToPrivateServer:

tpService:TeleportToPrivateServer(15852072777, rserverServer, plrs)
3 Likes

It fixed my issue! Thank you for your help!

I believe this is the problem. I assume that found.Value is a string, not a player instance. If my assumption is right, then you need to store the player instance onto the table, not the string, because the Teleport method from TeleportService needs to have a player instance, not a string. Also, I don’t think the table would work.

If you look at his image, found is an ObjectValue pointing to (presumably) Vlad’s Player object.
There are definitely better ways of creating that Table, but it’s not invalid.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.