Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local intermission = game.Workspace.GameStatus.Intermission
- local roundLength = game.Workspace.GameStatus.RoundLength
- local Winner = game.Workspace.GameStatus.Winner
- local Started = game.Workspace.GameStatus.Started
- local Teams = game.Workspace:WaitForChild("TeamChecker")
- local Chasers = Teams.Chasers
- local Runners = Teams.Runners
- local runTel = workspace.RunnerTelPart
- local chaseTel = workspace.ChaserTelPart
- _G.chaserTable = {}
- _G.runnerTable = {}
- local function gameOver ()
- roundLength.Value = 0
- end
- while true do
- wait()
- local players = game:GetService("Players")
- local playersTable = players:GetPlayers()
- local totalPlayers = #playersTable
- local maxChasers = math.floor(#playersTable / 3)
- if totalPlayers < 2 then continue end
- if totalPlayers == 2 then
- maxChasers = 1
- end
- for i = intermission.Value, 0, -1 do
- task.wait(1)
- intermission.Value -= 1
- end
- for i, player in ipairs(playersTable) do
- wait()
- local random = math.random(1,2)
- if math.floor(random) == 1 and player.Values.myTeam.Value == "Lobby" and totalPlayers > 2 then
- print(player.Name.." is a Runner")
- player.Values.myTeam.Value = "Runner"
- Runners.Value = Runners.Value + 1
- table.insert(_G.runnerTable, player)
- end
- if math.floor(random) == 1 and player.Values.myTeam.Value == "Lobby" and totalPlayers == 2 and Runners.Value <= 0 then
- print(player.Name.." is a Runner")
- player.Values.myTeam.Value = "Runner"
- Runners.Value = Runners.Value + 1
- table.insert(_G.runnerTable, player)
- elseif math.floor(random) == 1 and player.Values.myTeam.Value == "Lobby" and totalPlayers == 2 and Runners.Value >= 1 then
- print(player.Name.." is a Chaser")
- player.Values.myTeam.Value = "Chaser"
- Chasers.Value = Chasers.Value + 1
- table.insert(_G.chaserTable, player)
- end
- if math.floor(random) == 2 and Chasers.Value < maxChasers and player.Values.myTeam.Value == "Lobby" then
- print(player.Name.." is a Chaser")
- player.Values.myTeam.Value = "Chaser"
- Chasers.Value = Chasers.Value + 1
- table.insert(_G.chaserTable, player)
- elseif math.floor(random) == 2 and Chasers.Value >= maxChasers and player.Values.myTeam.Value == "Lobby" then
- print(player.Name.." is a Runner")
- player.Values.myTeam.Value = "Runner"
- Runners.Value = Runners.Value + 1
- table.insert(_G.runnerTable, player)
- end
- if player.Values.myTeam.Value == "Chaser" then
- player.Character.HumanoidRootPart.Position = chaseTel.Position
- end
- if player.Values.myTeam.Value == "Runner" then
- player.Character.HumanoidRootPart.Position = runTel.Position
- end
- end
- Started.Value = true
- repeat wait(1)
- roundLength.Value -= 1
- if #_G.chaserTable <= 0 then
- gameOver()
- end
- if #_G.runnerTable <=0 then
- gameOver()
- end
- until roundLength.Value <= 0
- if #_G.runnerTable >= 1 then
- print(#_G.runnerTable.." Runners survived")
- Winner.Value = #_G.runnerTable.." RUNNERS WON!"
- end
- if #_G.runnerTable <= 0 then
- Winner.Value = "CHASERS WON!"
- end
- Started.Value = false
- for i, player in ipairs(playersTable) do
- if player.Values.myTeam.Value == "Runner" then
- player.leaderstats.Wins.Value += 1
- player.Values.Coins.Value += 10
- player.Values.myTeam.Value = "Lobby"
- Runners.Value = Runners.Value - 1
- table.remove(_G.runnerTable, table.find(_G.runnerTable,player))
- end
- if player.Values.myTeam.Value == "Chaser" then
- if #_G.runnerTable <= 0 then
- player.leaderstats.Wins.Value +=1
- player.Values.Coins.Value += 10
- end
- player.Values.myTeam.Value = "Lobby"
- Chasers.Value = Chasers.Value - 1
- table.remove(_G.chaserTable, table.find(_G.chaserTable, player))
- end
- player.Backpack:ClearAllChildren()
- player.Values.HasTool.Value = false
- player.Character.Humanoid.Health = 0
- end
- players.PlayerRemoving:Connect(function(plr)
- local wasRunner = table.find(_G.runnerTable, plr )
- local wasChaser = table.find(_G.chaserTable, plr)
- if wasRunner then
- table.remove(_G.runnerTable, wasRunner)
- Runners.Value = Runners.Value - 1
- end
- if wasChaser then
- table.remove(_G.chaserTable, wasChaser)
- Chasers.Value = Chasers.Value - 1
- end
- end)
- Runners.Value = 0
- Chasers.Value = 0
- wait(5)
- intermission.Value = 10
- roundLength.Value = 120
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement