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

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