it stops working at divide teams.... Help?
print 'Running Game Script'
msg = Instance.new("Message",game.Workspace)
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 round(a,b)
return math.floor((a/b)+0.5)*b
end
function God_health()
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
player[i].Character.Humanoid.MaxHealth = 2000000
wait(1)
player[i].Character.Humanoid.Health = 2000000
end
end
end
function FindAlive() -- This it the checking part
if game.Players.NumPlayers < Plyrs then
h.Parent = game.Workspace
h.Text = "Not Enough Players"
else
h.Parent = game.Workspace
h.Text = "Enough Players!"
wait(1)
h.Text = "Starting Game..."
wait(3)
h:remove()
end
end
wait(25)-- Lobby Time
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
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
player[i].TeamColor.new = BrickColor.new("Medium stone grey")
end
end
end
function Explain_Game() -- Just explaining the game.
msg.Text = "Get Ready to play."
wait(5)
msg.Parent = nil
end
function Choose_map() -- Chooses The map and puts it in the workspace
maps = {}
for i,v in pairs(game.Lighting.Maps:GetChildren()) do
table.insert(maps,i,v.Name)
end
x = maps[math.random(1,#maps)]:clone()
x.Parent = game.Workspace
msg.Text = x.Name.." has been chosen!"
wait(5)
msg.Parent = nil
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Bright red") then
v.Character.Torso.CFrame = CFrame.new(Vector3.new(x.red.SpawnLocation.Position))
elseif v.TeamColor == BrickColor.new("Bright red") then
v.Character.Torso.CFrame = CFrame.new(Vector3.new(x.red.SpawnLocation.Position))
end
end
end
function gear_up() -- Gives all the players their guns
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
game.Lighting:findFirstChild("pistol"):clone().Parent = player.Backpack
end
end
end
function Un_God_health()
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
player[i].Character.Humanoid.MaxHealth = 100
wait(1)
player[i].Character.Humanoid.Health = 100
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
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
player.Backpack:findFirstChild("pistol"):remove()
end
end
end
function Back_to_lobby() -- Teleports everyone to the lobby
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
player.Character.Torso.CFrame = Cframe.new(vector3.new(-38, 16, 66.6)) -- Change to Correct Lobby Cordinance
end
end
function game_end() -- just waiting to the end of the round.
msg.Text = "times UP! now take some time and chilax."
wait(5)
msg.Parent = nil
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("red") then v:remove()
end
end
end
end
wait(1)
FindAlive() |