Now that I have looked over the script I see that something does actually happen after that wait time. The 'Find_Alive' function runs at the end. What this accomplishes though is absolutely nothing except counting to 2.
To fix this you will need to change a few functions and add a loop at the end,
which I did for you:
local Maps = game.lighting.Maps:GetChildren()
local Plyrs = 2
local KL = game.Teams:GetChildren()
local pickedMap = nil
local h = Instance.new("Hint")
wait(5)
function Find_Alive() -- I need to make sure there is atleast two people in the game b4 start
local alive = 0
local playersLIST = game.Players:GetChildren()
for i = 1, #players:GetChildren() do
if playersLIST[i].Alive.Value == true then
alive = alive+1
end
end
return alive
end
function Check_Alive() -- This it the checking part
if Find_Alive() < Plyrs then
h.Parent = game.Workspace
h.Text = "Not Enough Players"
wait(1)
return false
else
h.Parent = game.Workspace
h.Text = "Enough Players!"
wait(1)
h.Text = "Starting Game..."
wait(3)
h.Parent = nil -- Not COMPLETELY removed... more like on standby.
return true
end
end
function Lobby_Time() -- I added this :P
wait(25)
end
function Divide_Teams() -- Every players starts on the Grey Team. In otherwords the not playing team. I need this randomly divide the players on the grey team and put them on a active team
players = game.Players:GetChildren()
for i = 1, #players do
if (players[i] ~= nil) then
players[i].TeamColor = KL[math.random(1,#KL)].TeamColor -- Fixed it to do what you said but you'll want to change this later to split players evenly(or maybe not)
end
end
end
function Explain_Game() -- Just explaining the game.
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = "Get Ready to play."
wait(5)
msg.Parent = nil
end
function Choose_map() -- Chooses The map and puts it in the workspace
local pM = game.Lighting.Maps(math.random(1,#Maps))
pickedMap = pM:clone()
pickedMap.Parent = game.Workspace
end
function Map_name() -- desplays the map that was picked
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = "Map " ..pickedMap.Name.. " has been chosen"
wait(5)
msg.Parent = nil
end
function teleport_players() -- teleports players on each team to there side of the map.
players = game.Players:GetChildren()
for i = 1, #players do
if (players[i] ~= nil) then
if (players[i].TeamColor == BrickColor.new("Bright Red")) then
local location = pickedMap.Spawns.red:GetChildren()
players[i].Character.Torso.CFrame = CFrame.new(location.Position.x,location.Position.y+3, location.Position.z)
wait(1)
elseif (players[i].TeamColor == BrickColor.new("Bright Blue")) then
local location = pickedMap.Spawns.blue:GetChildren()
players[i].Character.Torso.CFrame = CFrame.new(location.Position.x,location.Position.y+3, location.Position.z)
end
end
end
end
function gear_up() -- Gives all the players their guns
players = game.Players:GetChildren()
for i = 1, #players do
if (players[i] ~= nil) then
game.Lighting:findFirstChild("pistol"):clone().Parent = player.Backpack
end
end
end
function game_start() -- just waiting to the end of the round.
wait(120)
end
function gear_Down() -- Gives all the players their guns -- or takes them away :P
players = game.Players:GetChildren()
for i = 1, #players do
if (players[i] ~= nil) then
player.Backpack:findFirstChild("pistol"):remove()
end
end
end
function Back_to_lobby() -- Teleports everyone to the lobby
players = game.Players:GetChildren()
for i = 1, #players do
if (players[i] ~= nil) then
players[i].Character.Torso.CFrame = CFrame.new(-38, 16, 66.6) -- Change to Correct Lobby Coordinance
end
end
end
function game_end() -- just waiting to the end of the round.
local msg = Instance.new("Message")
msg.Text = "times UP! now take some time and chilax."
wait(5)
msg.Parent = nil
game.Workspace.pickedMap:Remove()
end
wait(1)
while true do
Lobby_Time()
if (Check_Alive()) then
Divide_Teams()
Explain_Game()
Choose_map()
Map_name()
teleport_players()
gear_up()
game_start()
gear_Down()
Back_to_lobby()
game_end()
end
end
|