How to make a selected group of players teleport to a different game

Would it work with what I was already doing?

Yep, i had a similar project that i did, where i made a Queue room that teleports players, and once they step into a platform then that platform will start counting down, everyone who’s inside the zone will be teleported. You can then combine that zone module with tables it has something like Zone.Entered:Connect(function() and Zone.Leaving:Connect(function() something like that if they enter the zone then add them into the table but if they leave then remove them

I am currently working on a script for it… I will show you it when done. (Not using the zone thing)

Here it is! (The timer is counting down in another script)

local timer = game.StarterGui.timer

local AlivePlayers = {}

local inpart = workspace.inpart

local Players = game:GetService("Players")

local function PlayerAdded(Player)

local player = Players:GetPlayerFromCharacter(Player.Parent)

AlivePlayers[Player] = true

end

local function PlayerRemoved(Player)

local player = Players:GetPlayerFromCharacter(Player.Parent)

AlivePlayers[Player] = nil

end

if timer == 1 then

for Player,Value in pairs(AlivePlayers) do

game:GetService("TeleportService").Teleport(7195505851, Player)

end

end

inpart.Touched:Connect(PlayerAdded)

inpart.TouchEnded:Connect(PlayerRemoved)

are you putting the server scripts individually to players? if so that’s not gonna work out, instead only have 1 script for all the players. And don’t rely on touched because it’s not accurate i had problems with that when i made mine so i resulted in using zone module.

You will need to get a table of players that are in the circle (can be their name or userid)
Then, you will need to do a for loop which will go through every player in the table and teleport them one by one. Example:

local TeleportService = game:GetSerivce("TeleportService")
local gameid = 487316
local table1 = {"Shedletsky","DevHelpAccount"}
for i,v in pairs(table1) do
	local player = game.Players[v]
	TeleportService:Teleport(gameid, player)
end

But you’re pre setting it to the players. I want it so that on the touch, they are added to the table. And touch ended, they are removed. Any chance you could help me with that?

You can add a person to the table on touch.
You can remove a person from the table aswell when touch ended.
Example:

inpart = part that player is touching
playerstotp = {}
inpart.Touched:Connect(function(Player)
	table.insert(playerstotp, Player.Name)
end)
inpart.TouchedEnded:Connect(function(Player)
	table.remove(playerstotp, Player.Name)
end)

I have got this script now, and it won’t work…

local timer = game.StarterGui.timer
local inpart = workspace.inpart
local Players = game:GetService("Players")
local TeleportService = game:GetSerivce("TeleportService")
local GameId = 7195505851

playerstotp = {}
inpart.Touched:Connect(function(Player)
	table.insert(playerstotp, Player.Name)
end)
inpart.TouchedEnded:Connect(function(Player)
	table.remove(playerstotp, Player.Name)
end)

if timer == 1 then
	for i,v in pairs(playerstotp) do
		local player = game.Players[v]
		TeleportService:Teleport(GameId, player)
	end
end

any help would be nice :grinning_face_with_smiling_eyes:

What kind of an instance is “timer”? If it’s a text label then you should do
local timer = tonumber(game.StarterGui.Timer.Text)

It is an intvalue… this is being displayed on another script which does work. But this one doesn’t…

If it’s an int value then you forgot to add .Value at the end.
Proper variable: local timer = game.StarterGui.timer.Value

ok I will try that. I will get back to you if it doesn’t work

Sorry, this script is not working with this (I added .Value)

local timer = game.StarterGui.timer.Value
local inpart = workspace.inpart
local Players = game:GetService("Players")
local TeleportService = game:GetSerivce("TeleportService")
local GameId = 7195505851

playerstotp = {}
inpart.Touched:Connect(function(Player)
	table.insert(playerstotp, Player.Name)
end)
inpart.TouchedEnded:Connect(function(Player)
	table.remove(playerstotp, Player.Name)
end)

if timer == 1 then
	print(playerstotp)
	for i,v in pairs(playerstotp) do
		local player = game.Players[v]
		TeleportService:Teleport(GameId, player)
	end
end

May you please screenshot the errors in console?

I’m sorry, what do you mean by console?
I’m newish to scripting

Console is basically an output for errors/warnings/etc…
For an example if you do print(“Hello world”) the text “Hello world” will appear in console. Same with errors. If your script faces an error while running, it will output it in console. To access the console you simply need to press f9 in-game and select “Server” tab if the error came from a server script. If you are doing it in studio, you can just go to “VIEW” tab and select “Output”. It will be the same as console.

Oh I know what output is. Here it is:

At this point I am not sure. You should enable third party teleport in your game settings. It is probably not working because of something being wrong in your game or me just being really blind, but I am pretty sure that everything is right in that script. If you have a friend who scripts, you can ask them to look at the problem using team create. Don’t think I can help you with anything else, so good luck. My suggestion is to look in to other scripts.

I am really the only one of my friends or family who have a passion in scripting… I turned on third party teleports, and it will still not work. Even if I put print instead of the teleport function, it won’t print. I tried printing print(playerstotp)… nothing