So i was making a game and had it so 4 people are required to start the match and if there wasn't four people then the game would say waiting for four players. That is where the first problem comes in The gui disappears I don't know what I did to do that then, the whole script broke no error and i put print("Broke") to see if it breaks and it kept putting it I've tested it with four players nothing happens. I've been trying for 2 days already to fix it I want to add cut scenes every time the game starts, but I cant because the whole script is broken. I tried to make it so if a whole team dies the game ends, but idk if it broke the script pls help.!!
local replicatedStorage = game:GetService("ReplicatedStorage")
local Status = replicatedStorage:WaitForChild("Status")
local InGameBool = replicatedStorage:WaitForChild("InGame")
local MapsFolder = replicatedStorage:WaitForChild("Maps")
local Maps = MapsFolder:GetChildren()
local players = game:GetService("Players")
local plrs = game.Players
local survivors = {}
while wait() do
if #players:GetPlayers() > 4 then -- This is number of players required to start
print("Enough players!")
game.StarterGui.Timer.Timer.Text = "Get ready for deployment!"
while wait(20) do
InGameBool.Changed:Connect(function()
if InGameBool.Value == true then
-- Choose Map
local ChosenMap = Maps[math.random(1,#Maps)]
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = game.Workspace
wait(2)
-- Teleport Players To Map
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character or player.CharacterAdded:Wait()
char.HumanoidRootPart.CFrame = CFrame.new(ClonedMap.Spawn.Position) -- Teleports
end
-- If InGameBool Is False That Means Intermission
else
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character or player.CharacterAdded:Wait()
char.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.Lobby.SpawnLocation.Position) -- Teleports
end
-- Destroy The Old Map
for i,v in pairs (MapsFolder:GetChildren()) do
if game.Workspace:FindFirstChild(v.Name) then
local obj = game.Workspace[v.Name]
obj:Destroy()
end
end
end
end)
wait(3)
local chosen = plrs:GetChildren()[math.random(1, #plrs:GetChildren())]
chosen.PlayerGui.Job.Background.RoleGiven.Text = "The Children of Atonement"
chosen.PlayerGui.Job.Background.job.Text = "Don't let them stop you, kill them!"
chosen.PlayerGui.Job.Background.RoleGiven.TextColor3 = Color3.fromRGB(255, 0, 0)
chosen.PlayerGui.Job.Background.Visible = true
for i, plr in pairs(plrs:GetChildren()) do
if plr ~= chosen then
table.insert(survivors, plr)
plr.PlayerGui.Job.Background.RoleGiven.Text = "Task Force-20"
plr.PlayerGui.Job.Background.job.Text = "Take out the entity!"
plr.PlayerGui.Job.Background.RoleGiven.TextColor3 = Color3.fromRGB(0, 255, 0)
plr.PlayerGui.Job.Background.Visible = true
end
end
end
else
game.StarterGui.Timer.Timer.Text = "Waiting for 4 or more players!"
print("Broke")
end
end
local function changeTimer()
InGameBool.Value = false
for i = 10,0,-1 do -- ChangeIntermission Timer
wait(1)
Status.Value = "Intermission "..i.." Seconds Before New Match!"
end
InGameBool.Value = true
for i = 10,0,-1 do -- Change Intermission Timer
wait(1)
Status.Value = "In Game "..i.." Seconds Left Before Game Ends!"
end
end
while wait() do
changeTimer()
end
local function Entitydies ()
if players.Team.{"Children of Atonement"} == players.health == 0 then
changeTimer()
players.Team = 'At Lobby'
end
end
local function TaskForce20Death ()
if players.Team.{"Task Force-20"} == players.health == 0 then
changeTimer()
players.Team = 'At Lobby'
end
end
