Guest User

Untitled

a guest
Feb 15th, 2015
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.03 KB | None | 0 0
  1. local players = game.Players
  2.  
  3. local music = {177080835, 209864226, 164147183, 212675193, 181547615}
  4. local tem = "http://www.roblox.com/asset/?id="
  5.  
  6. local needed = 0
  7.  
  8.  
  9. function clearTable(chairs)
  10.     if #chairs >= 1 then
  11.     for k in pairs (chairs) do
  12.     chairs [k] = nil
  13.     end
  14.     end
  15. end
  16.  
  17. function round(num)
  18.     if num >= 0 then return math.floor(num+.5)
  19.     else return math.ceil(num-.5) end
  20. end
  21.  
  22.  
  23.  
  24. local function weldBetween(a, b)
  25.     local weld = Instance.new("ManualWeld")
  26.     weld.Part0 = a
  27.     weld.Part1 = b
  28.     weld.C0 = CFrame.new()
  29.     weld.C1 = b.CFrame:inverse() * a.CFrame
  30.     weld.Parent = a
  31.     return weld;
  32. end
  33.  
  34.  
  35. function circle(amount)
  36.     dev = 360/amount
  37.    
  38.    
  39.     for i=1, 360, dev do
  40.        
  41.        
  42.         local p = game.ServerStorage.Chair:Clone()
  43.        
  44.         p.Parent = game.Workspace
  45.        
  46.         p.Handle.CFrame = CFrame.new(-135,3,50)
  47.                     * CFrame.Angles(0, math.rad(i), 0)
  48.                     * CFrame.new(10,0,0)
  49.                    
  50.         p.Seat.Position = p.Handle.Position
  51.         weldBetween(p.Handle, p.Seat)
  52.                
  53.        
  54.     end
  55. end
  56.  
  57.     generate = false
  58.     balance = false
  59.     rounds = false
  60.     roundsmore = false
  61. while true do --main loop
  62.    
  63.  
  64.     wait()
  65.    
  66.     if script.playing.Value == false then -- loop until there is nuff players
  67.     repeat
  68.     hint = Instance.new("Hint")
  69.     hint.Text = "Need " .. needed - players.NumPlayers .. " More Players To Start"
  70.     hint.Parent = game.Workspace
  71.     wait()
  72.     until needed - players.NumPlayers <= 0
  73.     script.playing.Value = true
  74.     hint.Text = "Starting Game...."
  75.     wait(3)
  76.     end
  77.    
  78.     if script.playing.Value == true then
  79.        
  80.     --Generate the right amount of chairs for amount of players
  81.     if generate == false then
  82.     generate = true
  83.     hint.Text = "Preparing Map...."
  84.     amount = game.Players.NumPlayers +5
  85.     local dev = 360/amount
  86.     if amount < 0 == false or game.TestService == true then
  87.     circle(amount)
  88.     elseif amount < 0 == true and game.TestService == false then
  89.         hint.Text = "Server Broken D: Sorry. Autokicking..."
  90.         wait(5)
  91.         all = game.Players:GetChildren()
  92.         for i=1, #all do
  93.             all[i]:Kick()
  94.         end
  95.     end
  96.     end
  97.    
  98.    
  99.     -- Teleport Every Player
  100.     if balance == false then
  101.     balance = true
  102.     hint.Text = "Balancing Sides...."
  103.     players = game.Players:GetChildren()
  104.     section = #players / 2
  105.     sectionPart = round(section)
  106.     for i=1, sectionPart do
  107.         repeat wait() until players[i].Character
  108.         players[i].Character.Torso.CFrame = CFrame.new(game.Workspace.Area1.Position) + Vector3.new(0, 0, i * 5)
  109.     end
  110.     game.Workspace.blocker1.CanCollide = true
  111.     game.Workspace.blocker2.CanCollide = true
  112.     end
  113.    
  114.     -- Round 1
  115.     if rounds == false then
  116.     rounds = true
  117.     local rounds = game.Players.NumPlayers
  118.     chairs = {}
  119.    
  120.  
  121.    
  122.     children = game.Workspace:GetChildren()
  123.     for i=1, #children do -- put every chair in workspace into the table chairs
  124.         if children[i].Name == "Chair" then
  125.             table.insert(chairs, children[i])
  126.         end
  127.     end
  128.    
  129.     hint.Text = "Round 1"
  130.    
  131.     playTime = math.random(math.random(15,35)) 
  132.     songId = music[math.random(1, #music)]
  133.        
  134.     sound = Instance.new("Sound", game.Workspace)
  135.     stop = Instance.new("Sound", game.Workspace)
  136.     stop.SoundId = tem .. 138122923
  137.     sound.Looped = true
  138.     sound.SoundId = tem .. songId
  139.     sound:Play()
  140.     wait(playTime)
  141.     sound:Stop()
  142.     stop:Play()
  143.     hint.Text = "GET TO A CHAIR"
  144.     wait(5)
  145.     hint.Text = "Round Over!"
  146.     safe = {}
  147.     out = {}
  148.    
  149.     for i=1, #chairs do
  150.         guy = chairs[i].Seat.Sitting
  151.         table.insert(safe, guy.Value)
  152.     end
  153.    
  154.     for k, v in pairs(game.Players:GetChildren()) do
  155.         kill = true
  156.         for i=1, #safe do
  157.             if safe[i] == v.Name then
  158.                 kill = false
  159.             end
  160.         end
  161.        
  162.         if kill == true then
  163.             v.Character:BreakJoints()
  164. --          table.insert(out, v.Name)
  165.         end        
  166.     end
  167.    
  168. --  if #safe == 1 then
  169. --      --endgame()
  170. --     
  171. --  else
  172. --      clearTable(safe)
  173. --  end
  174.  
  175.    
  176.     -- next round (if needed)
  177.  
  178.    
  179.  
  180.    
  181.     for k, v in pairs(game.Workspace:GetChildren()) do
  182.         if v.Name == "Chair" then v:Destroy() else return end
  183.     end
  184.     local rounds = game.Players.NumPlayers
  185.     clearTable(chairs) 
  186.     chairs = {}
  187.    
  188.    
  189.     children = game.Workspace:GetChildren()
  190.     for i=1, #children do -- put every chair in workspace into the table chairs
  191.         if children[i].Name == "Chair" then
  192.             table.insert(chairs, children[i])
  193.         end
  194.     end
  195.    
  196.    
  197.     hint.Text = "Round 2"
  198.    
  199.     playTime = math.random(math.random(15,35)) 
  200.     songId = music[math.random(1, #music)]
  201.        
  202.     sound = Instance.new("Sound", game.Workspace)
  203.     stop = Instance.new("Sound", game.Workspace)
  204.     stop.SoundId = tem .. 138122923
  205.     sound.Looped = true
  206.     sound.SoundId = tem .. songId
  207.     sound:Play()
  208.     wait(playTime)
  209.     sound:Stop()
  210.     stop:Play()
  211.     hint.Text = "GET TO A CHAIR"
  212.     wait(5)
  213.     hint.Text = "Round Over!"
  214.     safe = {}
  215.     out = {}
  216.    
  217.     for i=1, #chairs do
  218.         guy = chairs[i].Seat.Sitting
  219.         table.insert(safe, guy.Value)
  220.     end
  221.    
  222.     for k, v in pairs(game.Players:GetChildren()) do
  223.         kill = true
  224.         for i=1, #safe do
  225.             if safe[i] == v.Name then
  226.                 kill = false
  227.                 break
  228.             end
  229.         end
  230.        
  231.         if kill == true then
  232.             v.Character:BreakJoints()
  233.             table.insert(out)
  234.         end        
  235.     end
  236.    
  237. --  if #safe == 1 then
  238. --      --endgame()
  239. --     
  240. --  else
  241. --      clearTable(safe)
  242. --  end
  243.  
  244.     end
  245.     end
  246. end
Advertisement
Add Comment
Please, Sign In to add comment