-- function Choose_Map is not working.... how do i fix?
print 'Running Game Script'
msg = Instance.new("Message",game.Workspace)
local mapDirectory = game.Lighting.Maps
local Maps = mapDirectory:getChildren()
local Plyrs = 1
local pickedMap = nil
local h = Instance.new("Hint")
wait(1)
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
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 Divide_Teams_one()
player = game.Players:GetPlayers()
for i = 1, #player do
if player[i].TeamColor == BrickColor.new("Mid grey") then
player[i].TeamColor = BrickColor.new("Bright blue")
end
end
end
function Divide_Teams_two()
player = game.Players:GetPlayers()
for i = 1, #player do
if player[i].TeamColor == BrickColor.new("Midium stone grey") then
player[i].TeamColor = BrickColor.new("Bright blue")
end
end
end
function Explain_Game() -- Just explaining the game.
h.Parent = game.Workspace
h.Text = "hmmm"
wait(1)
h:remove()
end
function Choose_map() -- Chooses The map and puts it in the workspace
local pickedMap = Maps[math.random(1, #Maps)]
local pickedMapClone = pickedMap:clone()
pickedMapClone.Parent = game.Workspace
pickedMapClone:makeJoints()
wait(3)
h.Parent = game.Workspace
h.Text = "Map : " ..pickedMapClone.Name.. " has been chosen!"
wait(3)
h:remove()
local x = pickedMap.Name
local Spawns = game.Workspace.x:FindFirstChild("Spawns")
player = game.Players:GetChildren()
for i = 1, #player do
if (player[i] ~= nil) then
if (player[i].TeamColor == BrickColor.new("Bright red")) then
player[i].Character.Torso.CFrame = CFrame.new(Vector3.new(x.Spawns.red.SpawnLocation.Position))
elseif (player[i].TeamColor == BrickColor.new("Bright blue")) then
player[i].Character.Torso.CFrame = CFrame.new(Vector3.new(x.Spawns.blue.SpawnLocation.Position))
end
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.
h.Parent = game.Workspace
h.Text = "Game Active"
wait(120)
h:remove()
end
function Remove_map()
game.Workspace.pickedMap:remove()
wait(3)
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)
function Lobby_Time()
wait(25)
end
wait(1)
while true do
Lobby_Time()
FindAlive()
God_health()
Divide_Teams_one()
Divide_Teams_two()
Explain_Game()
FindAlive()
Choose_map()
gear_up()
Un_God_health()
game_start()
Remove_map()
gear_Down()
Back_to_lobby()
game_end()
end
|