A button that teleports all player on the server

Hi!
How to make a button that teleports all players that are in your lobby?
~ Maini

2 Likes

Teleport to where ?

2 Likes

Teleport Within game…
Or
Outside of game…

Alot of details are missing a bit vague…

2 Likes

Bro, i dont asked for teleport within or outside the game, i asked how i can do that all players of the server get teleportet

and its outside

2 Likes

That was very confusing so you want to teleport them to a different game? If so. You will need to use TeleportService | Roblox Creator Documentation

Here just do.

Button.MouseButton1Down:Connect(function()
for i,v in pairs(game.Players:GetChildren()) do
v.Character.HumanoidRootPart.CFrame = TeleportPartCFrame
end
end)

I want to teleport all players from a game to another game!

As I said before you will use TeleportService | Roblox Creator Documentation

Specifically TeleportService | Roblox Creator Documentation

The example code from documentation

TeleportService:Teleport() from server

local TeleportService = game:GetService("TeleportService")
 
local placeId = 0 -- replace here
local userId = 1 -- replace with player's userId
 
-- find the player
local player = Players:GetPlayerByUserId(userId)
 
-- teleport the player
TeleportService:Teleport(placeId, player)

Since they want to teleport all of the players instead of just 1, I will rewrite what you wrote but with all players instead of just 1.

local TeleportService = game:GetService("TeleportService")
local TargetPlaceId = 0 --"Enter target place Id."
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
    TeleportService:Teleport(TargetPlaceId, Player)
end

Let me know if there are any errors with this code, if not and it works and answers your question @Mainixy , Please mark as solution.

2 Likes