I think I found the solution. Turns out my code in studio wasn’t working either, but I changed it up to this and it works like a charm now. Obviously you cannot teleport between places in studio, so it would error. This script should work 100%.
local gameId = 6331956095
for i, Player in pairs(game.Players:GetPlayers()) do
if Player:IsA("Player") then
game:GetService("TeleportService"):Teleport(gameId, Player)
end
end
Let me know if it still doesn’t work, because if it doesn’t it’s definitely something happening with your if statements (if you have any)
If you make a local script, it will only teleport that one player. In order to teleport everyone in the game, it must be a server script. Local Scripts can only affect the singular player unless a RemoteEvent is used.
Depends on what you’re going to use Teleport Service for.
To teleport all players, it must be a Server Script.
To teleport a client, it must be a Local Script.
How many people are you attempting to teleport? Are they teleporting to a game that is inside the same game? (Place-In-Place, also known as “Universe”)?
Also just a question, but what does the rest of your code look like for getting all players to teleport? You mentioned you only needed help on this one specific section but there could be a possibility something else in the script is causing an issue. I’ll do some more digging while you answer these questions.
I’m currently trying to teleport two players (me and my alt). I’m not trying to teleport to a sub game (I know that’s not what it’s called but that’s just what I call it). And the entire thing is made up of a group of scrips going back and fourth from server to client using remote events.
Do you know if these scripts are being fired more than once by accident? You stated TeleportService was getting bottled up with queued requests, when TeleportService can actually take a bit of people
I got the error for not teleporting in studio on all the clients, meaning it did attempt to teleport them all, but that’s not possible in studio itself. That’s why I feel as if theres an issue on your end. TeleportService could be acting up, It never is usually the fasting thing on the planet but it does get the job done.
edit There’s 2 errors cuz I added a yield at the beginning when the server started, then tried to teleport again using the command line in studio, both of which attempted to teleport all clients
I don’t got enough people for testing in a real client. Studio is basically just the roblox client, only without the actual teleport. If the teleport queue is filling up quick, then something might not be right with the debounce or the way you’re firing to the server
believe it or not, the same player who was already instructed to teleport from a script can be added to the queue again a second time, which is kinda dumb.
When your local script calls to the server script to teleport a player, just plug that players variable into the function
I mean where it says :Connect(function() you put :Connect(function(Player)
That way you can delete the for loop. I think this is what is causing the TeleportService to get bottled. ALL clients in the game are firing that 1 time, which will double the amount of players to actually have. Just get the gameid, then fire that individual player. Since all clients fire the server, they will all be teleported individually without the need of a for loop. Haven’t tested this, but hopefully you get what I mean.