i tried the function but it still doesnt run all the same time: here is my script that i modified because of the problem:
wait(2)
local intermissionLength = 5 -- Time in seconds of the time you in the lobby
local Status = game.ReplicatedStorage.Status
local Players = game:GetService("Players")
local InRound = game.ReplicatedStorage.InRound
local Maps = game:GetService("ServerStorage"):FindFirstChild("Maps")
local Rounds = game.ReplicatedStorage.Round
local PlayersInGame = {}
local LobbySpawn = game.Workspace.LobbySpawn
InRound.Changed:Connect(function()
if InRound.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
local Clone = workspace.Colors:WaitForChild("Map")
local randomColorchooser = math.random(1, #Clone:GetChildren())
local randomPart: Part = Clone:GetChildren()[randomColorchooser]
char.HumanoidRootPart.CFrame = randomPart.CFrame + Vector3.new(0,5,0)
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
end
end
end)
local function RemoveRound()
InRound.Value = false
local Map: Model = workspace.Colors:FindFirstChild("Map")
if Map then
Map:Destroy()
end
for i,v in ipairs(Players:GetChildren()) do
table.remove(PlayersInGame, table.find(PlayersInGame, v))
end
end
local function EliminatePlayer(plr)
table.remove(PlayersInGame, table.find(PlayersInGame, plr))
end
game.Players.PlayerRemoving:Connect(function(plr)
EliminatePlayer(plr)
end)
script.Die.Event:Connect(function(plr)
EliminatePlayer(plr)
end)
local function SetColorGui(Color, Player)
local PlayerColorGui: Frame = Player.PlayerGui.Core.Colors
local PlayerColorColorGui: Frame = PlayerColorGui.Color
local PlayerColorColorNameText: TextLabel = PlayerColorGui.ColorName
local PlayerColorTimerText: TextLabel = PlayerColorGui.Timer
PlayerColorGui.Visible = true
PlayerColorColorGui.BackgroundColor = Color
PlayerColorColorNameText.Text = Color.Name
for i = 5,0,-1 do
PlayerColorTimerText.Text = i
wait(1)
if i == 0 then
PlayerColorGui.Visible = false
return
end
end
end
local function PlayerWin(Plr: Player?)
for i,v in ipairs(Players:GetChildren()) do
local PlayerWinnerGui: Frame = v.PlayerGui.Core.Winner
local PlayerWinnerWinnersText: TextLabel = PlayerWinnerGui.Winners
PlayerWinnerGui.Visible = true
if not Plr then
PlayerWinnerWinnersText.Text = "Nobody"
else
PlayerWinnerWinnersText.Text = Plr.Name
end
wait(3)
PlayerWinnerGui.Visible = false
end
end
local function StartRound(Map)
Rounds.Value = Rounds.Value + 1
Status.Value = "Starting New Round..."
local Clone: Model
if not workspace.Colors:FindFirstChild("Map") then
Clone = Map:Clone()
Clone.Parent = workspace.Colors
Clone.Name = "Map"
end
local Clone = workspace.Colors:FindFirstChild("Map")
InRound.Value = true
Status.Value = "Round Started!"
for i, v in ipairs(Clone:GetChildren()) do
v.BrickColor = BrickColor.random()
end
local generatedrandomColor
local randomColorchooser = math.random(1, #Clone:GetChildren())
local randomPart: Part = Clone:GetChildren()[randomColorchooser]
generatedrandomColor = randomPart.BrickColor
wait(1)
Status.Value = "The generated Color is "..generatedrandomColor.Name
for i, v in ipairs(game.Players:GetChildren()) do
SetColorGui(generatedrandomColor, v)
end
for i, v in ipairs(Clone:GetChildren()) do
if v.BrickColor ~= generatedrandomColor then
v.Transparency = 1
v.CanCollide = false
end
end
wait(3)
for i, v in ipairs(Clone:GetChildren()) do
if v.BrickColor ~= generatedrandomColor then
v.Transparency = 0
v.CanCollide = true
end
end
end
while wait() do
if #Players:GetChildren() >= 1 then
if InRound.Value == false then
for i = intermissionLength, 0, -1 do -- "-1" is the seconds the timer goes down by
InRound.Value = false
wait(1)
Status.Value = "Intermission: ".. i .." Seconds.."
if i == 0 then
print("DEBUG")
Status.Value = "Generating Map Please Wait."
local RandomMapNumber = math.random(1, #Maps:GetChildren())
local RandomMap = Maps:GetChildren()[RandomMapNumber]
wait(1)
Status.Value = "The chosen map is ".. RandomMap.Name
wait(1.5)
for i,v in ipairs(Players:GetChildren()) do
table.insert(PlayersInGame, v)
end
wait(1)
while wait() do
if #PlayersInGame <= 0 then
Status.Value = "Ending Round."
wait(2)
local PlayerWinner
for i, v in ipairs(PlayersInGame) do
if v == nil then continue end
PlayerWinner = v.Name
print(PlayerWinner)
end
print(PlayerWinner)
if PlayerWinner == nil then
Status.Value = "Nobody Won!"
PlayerWin(nil)
else
local Player = game.Players:FindFirstChild(PlayerWinner)
print(Player)
Status.Value = "The winner is "..Player.Name
PlayerWin(Player)
end
RemoveRound()
break
else
StartRound(RandomMap)
end
wait(1)
end
end
end
end
else
Status.Value = "There isnt enough players to play the game, try inviting some friends or rejoin to another server!"
end
end
here is the original script:
wait(2)
local intermissionLength = 5 -- Time in seconds of the time you in the lobby
local Status = game.ReplicatedStorage.Status
local Players = game:GetService("Players")
local InRound = game.ReplicatedStorage.InRound
local Maps = game:GetService("ServerStorage"):FindFirstChild("Maps")
local Rounds = game.ReplicatedStorage.Round
local PlayersInGame = {}
local LobbySpawn = game.Workspace.LobbySpawn
InRound.Changed:Connect(function()
if InRound.Value == true then
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
local Clone = workspace.Colors:WaitForChild("Map")
local randomColorchooser = math.random(1, #Clone:GetChildren())
local randomPart: Part = Clone:GetChildren()[randomColorchooser]
char.HumanoidRootPart.CFrame = randomPart.CFrame + Vector3.new(0,5,0)
end
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
end
end
end)
local function RemoveRound()
InRound.Value = false
local Map: Model = workspace.Colors:FindFirstChild("Map")
if Map then
Map:Destroy()
end
for i,v in ipairs(Players:GetChildren()) do
table.remove(PlayersInGame, table.find(PlayersInGame, v))
end
end
local function EliminatePlayer(plr)
table.remove(PlayersInGame, table.find(PlayersInGame, plr))
end
game.Players.PlayerRemoving:Connect(function(plr)
EliminatePlayer(plr)
end)
script.Die.Event:Connect(function(plr)
EliminatePlayer(plr)
end)
local function SetColorGui(Color, Player)
local PlayerColorGui: Frame = Player.PlayerGui.Core.Colors
local PlayerColorColorGui: Frame = PlayerColorGui.Color
local PlayerColorColorNameText: TextLabel = PlayerColorGui.ColorName
local PlayerColorTimerText: TextLabel = PlayerColorGui.Timer
PlayerColorGui.Visible = true
PlayerColorColorGui.BackgroundColor = Color
PlayerColorColorNameText.Text = Color.Name
for i = 5,0,-1 do
PlayerColorTimerText.Text = i
wait(1)
if i == 0 then
PlayerColorGui.Visible = false
return
end
end
end
local function PlayerWin(Plr: Player?)
for i,v in ipairs(Players:GetChildren()) do
local PlayerWinnerGui: Frame = v.PlayerGui.Core.Winner
local PlayerWinnerWinnersText: TextLabel = PlayerWinnerGui.Winners
PlayerWinnerGui.Visible = true
if not Plr then
PlayerWinnerWinnersText.Text = "Nobody"
else
PlayerWinnerWinnersText.Text = Plr.Name
end
wait(3)
PlayerWinnerGui.Visible = false
end
end
local function StartRound(Map)
Rounds.Value = Rounds.Value + 1
Status.Value = "Starting New Round..."
local Clone: Model
if not workspace.Colors:FindFirstChild("Map") then
Clone = Map:Clone()
Clone.Parent = workspace.Colors
Clone.Name = "Map"
end
local Clone = workspace.Colors:FindFirstChild("Map")
InRound.Value = true
Status.Value = "Round Started!"
for i, v in ipairs(Clone:GetChildren()) do
v.BrickColor = BrickColor.random()
end
local generatedrandomColor
local randomColorchooser = math.random(1, #Clone:GetChildren())
local randomPart: Part = Clone:GetChildren()[randomColorchooser]
generatedrandomColor = randomPart.BrickColor
wait(1)
Status.Value = "The generated Color is "..generatedrandomColor.Name
SetColorGui(generatedrandomColor, v)
for i, v in ipairs(Clone:GetChildren()) do
if v.BrickColor ~= generatedrandomColor then
v.Transparency = 1
v.CanCollide = false
end
end
wait(3)
for i, v in ipairs(Clone:GetChildren()) do
if v.BrickColor ~= generatedrandomColor then
v.Transparency = 0
v.CanCollide = true
end
end
end
while wait() do
if #Players:GetChildren() >= 1 then
if InRound.Value == false then
for i = intermissionLength, 0, -1 do -- "-1" is the seconds the timer goes down by
InRound.Value = false
wait(1)
Status.Value = "Intermission: ".. i .." Seconds.."
if i == 0 then
print("DEBUG")
Status.Value = "Generating Map Please Wait."
local RandomMapNumber = math.random(1, #Maps:GetChildren())
local RandomMap = Maps:GetChildren()[RandomMapNumber]
wait(1)
Status.Value = "The chosen map is ".. RandomMap.Name
wait(1.5)
for i,v in ipairs(Players:GetChildren()) do
table.insert(PlayersInGame, v)
end
wait(1)
while wait() do
if #PlayersInGame <= 0 then
Status.Value = "Ending Round."
wait(2)
local PlayerWinner
for i, v in ipairs(PlayersInGame) do
if v == nil then continue end
PlayerWinner = v.Name
print(PlayerWinner)
end
print(PlayerWinner)
if PlayerWinner == nil then
Status.Value = "Nobody Won!"
PlayerWin(nil)
else
local Player = game.Players:FindFirstChild(PlayerWinner)
print(Player)
Status.Value = "The winner is "..Player.Name
PlayerWin(Player)
end
RemoveRound()
break
else
StartRound(RandomMap)
end
wait(1)
end
end
end
end
else
Status.Value = "There isnt enough players to play the game, try inviting some friends or rejoin to another server!"
end
end