How would I make my game teleport someone to a different game on join (and with exceptions)

I’m trying to make a game which is just fully open but people get teleported to somewhere else unless they’re in a certain group, can someone help me do this? Thanks :slight_smile:

1 Like

Im confused what your trying to do. Like are you trying to make a private server that they are teleported too? Are you trying to teleport them to a side game?

So

Once a player joins the game I want to just immediately teleport them to a different game which is a sort-of coming soon place but if you’re in a certain list you don’t get teleported

Not a private server - a different game ID / side game

Ohh so your making like a testing place and only those on the list can test the rest are yeeted?

1 Like

You mean you’re trying to make something, that when a player joins they get teleported to a different game right?

1 Like

Well please read the Teleporting Between Places docs

Ohhh, then you can probably do something like

local List = {} -- List of player UserIds'
local TPS = game:GetService("TeleportService")

game.Players.PlayerAdded:Connect(function(player)
    for _, userId in pairs(List) do
        if player.UserId == userId then
            TPS:Teleport(123456789, player) -- Place id here
        else
            print(player.Name .. "isn't in the list!")
            player:Kick("You were not on the list!") -- Random stuff
        end
    end
end)

Sorry if the code wasn’t formatted well, I wrote it here on the forum.

1 Like

Unable to cast value to Object on line 5

would I need to enable something? I feel like I disabled something

Can you send error message that you got.

Have you turned on Third party Teleports on game settings?

Yeah, still gives the exact same error

What’s the line 5? the UserId check or the teleport?

for _, userId in pairs(List) do

1 Like

Where is this script meant to be I might’ve done that wrong

Have you put the UserIds’ in the table?

In ServerScriptService(Obviously a normal Script)

I have but I think I did it wrong one second

Have you added names to the list?

It’s UserId since players can change their usernames and I you probably don’t want to take that risk