I made 2 scripts. One script sets an intermission time in the lobby, and when it’s done it sets a timer for the game map and teleports the players to the game area. The other script organizes the teams by selecting one random user to be on Death while everyone else are Runners.
Team Organizing Script:
local plrs = game.Players
local runners = {}
local death = game.Teams.Death
local runners = game.Teams.Runners
inRound = game.ReplicatedStorage.InRound
while wait(10) do
local chosen = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]
for i, plr in pairs(plrs:GetChildren()) do
if plr ~= chosen then
table.insert(runners, plr)
plr.Team = runners
else
plr.Team = death
end
end
end
Round/Intermission Timer Script:
local music = game.Workspace.music
local music1 = game.Workspace.music_duplex
local title = game.StarterGui.Menu.TitleScreen
InRound.Changed:Connect(function()
if InRound.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = gamespawn.CFrame
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = lobbyspawn.CFrame
end
end
end)
local function RoundTimer()
while wait() do
music:Play()
music1:Stop()
for i = intermissionLength, 0, -1 do
InRound.Value = false
wait(1)
status.Value = "Intermission: ".. i .." seconds left!"
end
music:Stop()
music1:Play()
for i = roundLength, 0, -1 do
InRound.Value = true
wait(1)
status.Value = "Game: ".. i .." seconds left!"
end
end
end
spawn(RoundTimer)
Individually they work fine, but I needed to organize the teams when the round started instead of all the time. So, in the team script, instead of “while wait(10) do” I put “while InRound do” so it would only do teams when the round was in session. It didn’t work. I tried similar variations of the code, but I couldn’t figure it out. Anyone have any idea on how I could figure this out? If I organize the teams when the round starts I could teleport Death to a different starting location than the other team.
Any help would be greatly appreciated!