Hello!
I was wondering if anyone had a script where they get all the players in the game and teleport them into a new game.
Atm I got this:
local TeleportService = game:GetService(“TeleportService”)
local placeID_1 = (7057409796)
local function onPartTouch(otherPart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parnet)
if player then
TeleportService:Teleport(placeID_1, player)
end
end
local TeleportService = game:GetService(“TeleportService”)
local placeIDOne = 7057409796
for i, localPlayer in pairs(game.Players:GetChildren()) do
TeleportService:Teleport(placeIDOne,localPlayer
end
If You want to Teleport the Player Every time A Player Joins,
Use
local TeleportService = game:GetService(“TeleportService”)
local placeIDOne = 7057409796
game.Players.PlayerAdded:Connect(function(Player)
TeleportService:Teleport(placeIDOne,Player)
end)
Make Sure The Above Scripts Are in A Script and Not A LocalScript.
This will get All Players and Teleport them.
I have not used teleport service so much but here you go you can use this for when player touches a part he gets moved:
local TeleportService = game:GetService(“TeleportService”)
local PlaceId = otherGameId
local Players = game:GetService("Players")
local playerTpDebounce = false -- you can use debounce for more safety
local function TeleportToOtherGame(h)
local player = Players:GetPlayerFromCharacter(h.Parent)
if player and playerTpDebounce == false then
playerTpDebounce = true
TeleportService:Teleport(PlaceId,player)
wait(0.5)
playerTpDebounce = false
end
end)
script.Parent.Touched:Connect(TeleportToOtherGame)
Edit: I did not read that you wanted all the players to be moved, my bad. Heres how you can do it
Insert a ServerScript into ServerScriptService, you can use remote events to know when you want to move the players if you want though.
local TeleportService = game:GetService(“TeleportService”)
local PlaceId = otherGameId
local Players = game:GetService("Players")
for i, plr in pairs(Players:GetChildren()) do
TeleportService:Teleport(PlaceId,plr)
end
Its like a thing where players join the main game. After like 30 secs they get teleported (As a group) To a new game the play it and then they get teleported back for a new round.