I have made it so i teleport a bunch of players to different locations, but sometimes they go to the same location. I want to assign every teleporting player a different location to teleport to all random. So if i have 8 players and 8 locations, every player has his own location. As if right now i can get random teleports but they can spawn on the same location. I have used the following code:
``
local lobbyLocation = game.Workspace.Lobby.Lobby.Position + Vector3.new(0,3,0)
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local timeEvent = ReplicatedStorage:WaitForChild('TimeEvent')
local function playGame()
local timeAmount = 20
local timerText = 'Remaining Time: '
while timeAmount > 0 do
timeEvent:FireAllClients(timeAmount, timerText)
wait(1)
timeAmount -= 1
end
end
local function playIntermission()
local intermission = 10
local timerText = 'Intermission: '
while intermission > 0 do
timeEvent:FireAllClients(intermission, timerText)
wait(1)
intermission -= 1
end
end
local function resetPlayers()
for _, plr in pairs(game.Players:GetChildren()) do
plr.Character.HumanoidRootPart.CFrame = CFrame.new(lobbyLocation)
end
end
local function teleportPlayers()
local plrs = game.Players:GetChildren()
for i = 1, #plrs do
local num = math.random(1,9)
plrs[i].Character.Head.CFrame =
CFrame.new(workspace.Teleports["Main"..num].Position)
end
end
while true do
resetPlayers()
playIntermission()
teleportPlayers()
playGame()
end

1 comment
Why not try Teams and make it so 1 player max in each one? The spawn has a team assigned to it.