How could I do this?

this code is going to check the ID if its in your games list (the table) it will fire the clients to teleport to the game

your going to need to put the teleport service at the start of the game.
local TeleportService = game:GetService(“TeleportService”)

put a remote event into replicated storage

heres your code put it where ou have your current one as a normal script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RE = ReplicatedStorage:WaitForChild("RemoteEvent")
print("yo")
local GameList =  {GameID1, GameID2, ect} --put you game IDS here as a whitelist of games
script.Parent.MouseButton1Click:Connect(function()
	for i,GameID in pairs(GameList) do 
		if  script.Parent.Parent.Type.Text == GameID then  
			print("yes")
			RE:FireAllClients(GameID)
		else
			print("nope")
			wait(1)
		end	
	end
end)

put this code into starter player scripts as a local script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerID = Player.UserId
local RE = ReplicatedStorage:WaitForChild("RemoteEvent")
local TeleportService = game:GetService("TeleportService")

RE.OnClientEvent:Connect(function(GameID)
	TeleportService:Teleport(GameID, PlayerID)
end)

You can actually teleport singular players from the client but in the case of teleporting multiple players where you need a remote event you definitely need to add some form of sanity checks like checking if they are a high enough rank to use the teleport or not, unless this is available to all players which in that case wouldn’t really matter since you might as well just use the UI instead of going through the trouble of attaching your executor, writing the code, and executing it.

oh ive done it as teleport all the players to a game if someone types a code assuming its a mini game starter or something probably should’ve asked for more context before hand my bad

 15:58:46.086  Argument 2 missing or nil  -

error on line

TeleportService:TeleportPartyAsync()

In this error it’s… true to it’s word I suppose? Anyways, Argument 2 missing or nil means that you didn’t specify a second argument. TeleportPartyAsync() requires 2, and you only passed 1. Read about the function here and then ask questions if you get stuck.

sorry i miss read it earlier here you go

--put this as a local script in StarterPlayer>StarterPlayerScripts
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerID = Player.UserId
local GameWhiteList = {GameID, GameID, ect, ect}
local TeleportService = game:GetService("TeleportService")

script.Parent.MouseButton1Click:Connect(function()
	for i,v in pairs(GameWhiteList) do 
		if script.Parent.Parent.Type.Text == GameWhiteList then 
			TeleportService:Teleport(GameID, PlayerID)
		else
			continue
		end
	end
end)

script run through
– variables
–mouse button clicked
– checks if the text is in the gameids white list
– if it is it teleports if it isnt it continues to go through the table
– if it isnt in the table at all it ends

not quite what I was looking for but, still thanks.

do you want it to teleport if its any possible game ID?

some people are confused let me send screen shots of what i want

You do not have to loop; you can use table.find().

local plrid = game.Players.LocalPlayer.UserId
local ID
local TeleportService = game:GetService("TeleportService")

script.Parent.MouseButton1Click:Connect(function()

-- In here, check what the player has input into the text button.
-- Set what they typed in to the ID
-- For instance, you would have to check what the player typed into the textbox, then set that to ID
TeleportService:Teleport(plrid, ID)
end)

So basically explaining that script: you need to check what the player typed in, then set what they typed in to ID.

Okay since alot of you are confused let me make this easier to understand.

So this image below…


If I type any gameID like piggy…bloxburg… ANY game.
in the text box and I click the text button that says “enter” and if the gameId code exists then it teleports me to THAT game I typed in. If the gameId is invalid aka not a existing gameID then it prints out “Not a existing game” and it keeps them in the same/Current game they’re in .

sorry i miss read it earlier here you go

--put this in the same place as your script
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerID = Player.UserId
local TeleportService = game:GetService("TeleportService")

script.Parent.MouseButton1Click:Connect(function()
		local GameID = tonumber(script.Parent.Parent.Type.Text)
		TeleportService:Teleport(GameID, PlayerID)
end)

script run through
– variables
–mouse button clicked
–teleport

I know what you are trying to do.

sorry yeah i messed it up for a sec but now it should work
changed enumerate to “tonumber”
cause i got mixed up for a sec
(it should work now)
and if the ID is invalid it should just fail and there you have it

If thats in StarterPlayer>StarterPlayerScripts, when you said script.Parent wouldnt that be registering StarterPlayer?
Judging by his explorer, change that to
game.StarterGui.ScreenGui.Backround.Enter

Error: (11,1) Syntax error: Expected ')' (to close '(' at line 7), got 'end'

yeah dont put it in starterplayer scripts shove it in where you had the last one also ive edited the script so it should DEFINITELY work now

in the GUI somwhere

just so that the script.Parent.Parent.Type.Text matches up

Like I said, there’s a error.

Error: (11,1) Syntax error: Expected ')' (to close '(' at line 7), got 'end'

Why do you have an extra end? Remove the one above the last end) .