Tower defense game elevator

so im making a tower defense game, i made a simple lobby, but i just cant figure out how to teleport all players in the elevator into the game. i tried using teleportservice:reserveserver(), it just didnt teleport the players, i have no idea how to do this.

here is the current code for the elevator:

local code = game:GetService("TeleportService"):ReserveServer(7393530683)

function onTouched(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		game:GetService("TeleportService"):Teleport(7393530683,code,player)
	end
end


script.Parent.Touched:connect(onTouched)

Hello there, the :ReserveServer() function only works with :TeleportToPrivateServer()

I suggest you change your script to:

local code = game:GetService("TeleportService"):ReserveServer(7393530683) 

function onTouched(hit)
 local player = game.Players:GetPlayerFromCharacter(hit.Parent)
 if player then
  game:GetService("TeleportService"):TeleportToPrivateServer(7393530683,code,player)
    end
end 

script.Parent.Touched:connect(onTouched)

Replace the code with this and see if it works.

The best way is probably to put the player’s id on a table when they touched the elevator. Then you can teleport that player’s character inside of the elevator. And you could have a UI that will be able to make them leave the elevator/queue. If so, remove that player’s id from the previous table. Next, have a countdown. After the countdown ends, check whether the player in the table’s character is still inside of the Elevator. Then, if they are still there, teleport them to the game place or you could also have a function that makes the elevator go down just like in Tower Defense Simulator itself! After they’ve teleported, remove all the player’s ids from the table and reserve a new one. You could use an existing table or make a new table after they’ve teleported into the game. Either way, the choice is yours.

Method above is an OOP. LocalScript won’t work, you have to handle it through a server if I’m correct so you need to do a bit of research on how OOP works, and how they are being processed. Anyway, good luck.