SHARE
TWEET

Dashed

DomoBattler Jul 21st, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. testing = false
  2.  
  3. nowait = false
  4.  
  5. Leaderboard.CreateTeam("Playing", PartColor.new(0, 200, 0))
  6. Leaderboard.CreateTeam("Spectating", PartColor.new(50, 50, 50))
  7.  
  8. --Player Variables--
  9. playercount = 0 --Number of players on the server.
  10. playing = false --If the game is being played.
  11. playerstostart = 1 --Min num of players to start round
  12.  
  13. --Map Variables--
  14. maps = {"Bricks", "Sand", "Slim", "Squares", "FloodedTown"} --Maps MAKE SURE TO ADD TO RESETMAPS() AND LOADMAP()
  15. mapcount = 5 --Map count
  16. countdownnumber = 15 --Countdown Game
  17. roundtime = 60 --Gameplay Game
  18. mapselect = false --If players are selecting map
  19. votedebunk = false
  20.  
  21. playerteleporting = 0 --This is the number of spawns that are being used.
  22.  
  23. --Choices--
  24. pad1 = 0 --Pad1 Votes
  25. pad2 = 0 --Pad2 Votes
  26. pad3 = 0 --Pad3 Votes
  27. pad1c = 0 --Pad1 Votes
  28. pad2c = 0 --Pad2 Votes
  29. pad3c = 0 --Pad3 Votes
  30. --Players who voted--
  31. pad1players = {}
  32. pad2players = {}
  33. pad3players = {}
  34.  
  35. --Players playing--
  36. currentlyplaying = {}
  37.  
  38. --Part Variables--
  39. gamesign = Workspace.GameSign
  40.  
  41. if testing then
  42.     countdownnumber = 10
  43.     roundtime = 10
  44.     Workspace.PlayArea.Cheat.Opacity = 255
  45.     Workspace.PlayArea.Cheat.CanCollide = true
  46. end
  47.  
  48. if nowait then
  49.     countdownnumber = 0
  50.     roundtime = 0
  51.     Workspace.PlayArea.Cheat.Opacity = 255
  52.     Workspace.PlayArea.Cheat.CanCollide = true
  53. end
  54.  
  55. ---------------------------------------------------------------------------
  56.  
  57. --Functions--
  58. --Choosing Map--
  59. function choosemap()
  60.     Workspace.PlayArea.HowLong.Text = "Choosing Map!"
  61.     mapselect = true
  62.     for i,v in pairs(Workspace.GamePads:GetChildren()) do
  63.         local choosing = maps[math.random(1, mapcount)]
  64.         if v.Name == "GamePad1" or v.Name == "GamePad2" or v.Name == "GamePad3" then
  65.             v:FindFirstChild("MapName").Text = choosing
  66.             if i == 1 then
  67.                 pad3c = choosing
  68.             elseif i == 2 then
  69.                 pad2c = choosing
  70.             elseif i == 3 then
  71.                 pad1c = choosing
  72.             end
  73.         else
  74.             mapselect = false
  75.             choosemap()
  76.             break
  77.         end
  78.     end
  79.     if mapselect then
  80.         countdown()
  81.     end
  82. end
  83.  
  84. --Basically the start countdown--
  85. function countdown()
  86.     gamesign.Text.StatusChange.Text = "Choosing Map!"
  87.     local countdownnumber2 = countdownnumber
  88.     for i = 1, countdownnumber do
  89.         gamesign.Text.StatusChange.Text = ("Choosing Map! ".. countdownnumber2)
  90.         countdownnumber2 = countdownnumber2 - 1
  91.         wait(1)
  92.     end
  93.     gamesign.Text.StatusChange.Text = ("Game in progress!")
  94.     mapselect = false
  95.     playing = true
  96.     loadmap() --Calls Loadmap
  97. end
  98.  
  99. --Load map and updates votes--
  100. function loadmap()
  101.     local choice = nil
  102.  
  103.     if pad1 > pad2 and pad1 > pad3 and (choice == nil) then
  104.         choice = pad1c
  105.     elseif pad2 > pad1 and pad2 > pad3 and (choice == nil) then
  106.         choice = pad2c
  107.     elseif pad3 > pad1 and pad3 > pad2 and (choice == nil) then
  108.         choice = pad3c
  109.     elseif pad1 == pad2 and pad1 == pad3 and pad2 == pad3 and (choice == nil) then
  110.         local choices = {pad1c, pad2c, pad3c}
  111.         choice = (choices[math.random(1,3)])
  112.     elseif pad1 == pad2 and pad1 > pad3 and pad2 > pad3 and (choice == nil) then
  113.         local choices = {pad1c, pad2c}
  114.         choice = (choices[math.random(1, 2)])
  115.     elseif pad2 == pad3  and pad2 > pad1 and pad3 > pad1 and (choice == nil)  then
  116.         local choices = {pad2c, pad3c}
  117.         choice = (choices[math.random(1, 2)])
  118.     end
  119.    
  120.     Workspace.Island.MapName.Text = tostring(choice)
  121.         if choice == "Bricks" then
  122.             for i,v in pairs(Workspace.PlayArea.Maps.Bricks:GetChildren()) do -- ERRORS
  123.                 v.Opacity = 255
  124.                 v.CanCollide = true
  125.             end
  126.         elseif choice == "Sand" then
  127.             for i,v in pairs(Workspace.PlayArea.Maps.Sand:GetChildren()) do -- ERRORS
  128.                 v.Opacity = 255
  129.                 v.CanCollide = true
  130.             end
  131.         elseif choice == "Slim" then
  132.             for i,v in pairs(Workspace.PlayArea.Maps.Slim:GetChildren()) do -- ERRORS
  133.                 v.Opacity = 255
  134.                 v.CanCollide = true
  135.             end
  136.         elseif choice == "Squares" then
  137.             for i,v in pairs(Workspace.PlayArea.Maps.Squares:GetChildren()) do -- ERRORS
  138.                 v.Opacity = 255
  139.                 v.CanCollide = true
  140.             end
  141.         elseif choice == "FloodedTown" then
  142.             for i,v in pairs(Workspace.PlayArea.Maps.FloodedTown:GetChildren()) do -- ERRORS
  143.                 v.Opacity = 255
  144.                 v.CanCollide = true
  145.             end
  146.         end
  147.         resetpads("Game in progress!") --Changes pads text to message
  148.         wait(3)
  149.         teleportmap() --Teleporting players to map
  150.         updatevotes() --Updates votes to 0
  151. end
  152.  
  153. --Teleporting players to map--
  154. function teleportmap()
  155.     local whichspawn = 1
  156.     local players = Players.GetPlayers()
  157.     for index, player in pairs(players) do
  158.         if player.Health >= 1 then
  159.             player.Position = Workspace.PlayArea.Spawns:FindFirstChild("Spawn"..whichspawn).Position
  160.             Leaderboard.SetPlayerTeam(player, "Playing")
  161.             table.insert(currentlyplaying, player.Username)
  162.         end
  163.         whichspawn = whichspawn + 1
  164.     end
  165.     startgame()
  166. end
  167.  
  168. --Resets pads to message--
  169. function resetpads(message)
  170.     for i,v in pairs(Workspace.GamePads:GetChildren()) do
  171.         if v.Name == "GamePad1" or v.Name == "GamePad2" or v.Name == "GamePad3" then
  172.             v:FindFirstChild("MapName").Text = (message)
  173.         else
  174.             resetpads()
  175.         end
  176.     end
  177. end
  178.  
  179. function resetpos(player)
  180.     for i,v in pairs(Players.GetPlayers()) do
  181.         if Leaderboard.GetPlayerTeam(v) == "Playing" then
  182.             if player.Health > 0 then
  183.                 player.Position = Vector3.new(3.16, 5, 16.9)
  184.             end
  185.         end
  186.     end
  187. end
  188.  
  189. --Resets all--
  190. function resetwhole()
  191.     currentlyplaying = {}
  192.     local players = Players.GetPlayers()
  193.     for index, player in pairs(players) do
  194.         resetpos(player)
  195.         Leaderboard.SetPlayerTeam(player, "Spectating")
  196.     end
  197.     for i,v in pairs(Workspace.PlayArea.PlatformStart:GetChildren()) do
  198.         v.Opacity = 255
  199.         v.CanCollide = true
  200.    
  201.     end
  202.     Workspace.PlayArea.HowLong.Text = "Choosing Map!"
  203.     pad1c = 0 --Pad1 Votes
  204.     pad2c = 0 --Pad2 Votes
  205.     pad3c = 0 --Pad3 Votes
  206.     resetmap()
  207.     pad1 = 0
  208.     pad1players = {}
  209.     pad2 = 0
  210.     pad2players = {}
  211.     pad3 = 0
  212.     pad3players = {}
  213.     playing = false
  214.     playerteleporting = 0
  215.     updatevotes()
  216.     checking()
  217.  
  218. end
  219.  
  220. function checkingplaying()
  221.     local found = false
  222.     for i,v in pairs(Players.GetPLayers()) do
  223.         if Leaderboard.GetPlayerTeam(v) == "Playing" then
  224.             found = true
  225.             break
  226.         end
  227.     end
  228.     return(found)
  229. end
  230.  
  231. --When the game is running--
  232. function startgame()
  233.     local countdownnumber3 = 0
  234.     for i = 1, (roundtime * 10) do
  235.         if playing then
  236.             if i >= 10 then
  237.                 Workspace.PlayArea.HowLong.Text = tostring(countdownnumber3):sub(1, 4)
  238.             else
  239.                 Workspace.PlayArea.HowLong.Text = tostring(countdownnumber3):sub(1, 3)
  240.             end
  241.             if checkingplaying() then
  242.                 countdownnumber3 = countdownnumber3 + 0.1
  243.                 wait(0.08)
  244.             else
  245.                 break
  246.             end
  247.         else
  248.             break
  249.         end
  250.         if i > 100 and i < 110 then
  251.             for i,v in pairs(Workspace.PlayArea.PlatformStart:GetChildren()) do
  252.                 v.Opacity = 100
  253.                 v.CanCollide = false
  254.    
  255.             end
  256.         end
  257.     end
  258.     wait(1)
  259.     Workspace.PlayArea.HowLong.Text = "Game Over!"
  260.     resetwhole()
  261. end
  262.  
  263. --Clears the play area--
  264. function resetmap()
  265.     local placement = Workspace.PlayArea.Maps
  266.     resetmap2(placement.Bricks)
  267.     resetmap2(placement.Sand)
  268.     resetmap2(placement.Slim)
  269.     resetmap2(placement.Squares)
  270.     resetmap2(placement.FloodedTown)
  271. end
  272.  
  273. function resetmap2(map)
  274.     for i,v in pairs (map:GetChildren()) do
  275.         v.Opacity = 0
  276.         v.CanCollide = false
  277.     end
  278. end
  279.  
  280. function checkplayers(looking)
  281.     if #currentlyplaying >= 1 then
  282.         for i,v in pairs(currentlyplaying) do
  283.             if v == looking then
  284.                 table.remove(currentlyplaying, i)
  285.                 break
  286.             end
  287.         end
  288.     end
  289.     if not currentplaying then
  290.         resetwhole()
  291.     end
  292. end
  293.  
  294.  
  295. --Checking the playercount, and min player--
  296. function checking()
  297.     if playing == false and playercount >= playerstostart then
  298.         gamesign.Text.StatusChange.Text = "Choosing Map!"
  299.         choosemap()
  300.         --Not Playing with not meeting Player requirement--
  301.         else if playing == false and playercount < playerstostart then
  302.             gamesign.Text.StatusChange.Text = "Waiting For Players!"
  303.             resetpads("Waiting for players")
  304.            
  305.         end
  306.     end
  307. end
  308.  
  309. --Updates the gamepad text for votes--
  310. function updatevotes()
  311.     Workspace.GamePads.GamePad1.Votes.Text = pad1
  312.     Workspace.GamePads.GamePad2.Votes.Text = pad2
  313.     Workspace.GamePads.GamePad3.Votes.Text = pad3
  314. end
  315.  
  316.  
  317. --------------------------------------------------------------------------
  318.  
  319. --Game Sign Status--
  320. Players.PlayerJoined:Connect(function(Player)
  321.     Leaderboard.SetPlayerTeam(Player, "Spectating")
  322.     getplayercount()
  323.     --Checking for game off and playercount.
  324.     checking()
  325. end)
  326.  
  327.  
  328. Players.PlayerLeft:Connect(function(Player)
  329.     getplayercount()
  330.     --Checking for game off and playercount.
  331.     checking()
  332. end)
  333.  
  334. function getplayercount()
  335.     local playercount2 = 0
  336.     local players = Players.GetPlayers()
  337.     for index, player in pairs(players) do
  338.         playercount2 = playercount2 + 1
  339.     end
  340.     playercount = playercount2
  341. end
  342.  
  343. --------------------------------------------------------------------------
  344.  
  345. --Pad1--
  346. Workspace.Sensors.Sensor1.Touched:Connect(function(hit)
  347.     if hit:isA("Player") and mapselect == true then
  348.         hit.Position = Vector3.new(math.random(0, 6.5), 1, 14)
  349.         local found = false
  350.         if found == false then
  351.             for i,v in pairs(pad1players) do
  352.                 if hit.Username == v then
  353.                     found = true
  354.                     break
  355.                 end
  356.             end
  357.         end
  358.         if found == false then
  359.             for i,v in pairs(pad2players) do
  360.                 if hit.Username == v then
  361.                     found = true
  362.                     pad2 = pad2 - 1
  363.                     table.remove(pad2players, i)
  364.                     table.insert(pad1players, hit.Username)
  365.                     pad1 = pad1 + 1
  366.                     break
  367.                 end
  368.             end
  369.         end
  370.         if found == false then
  371.             for i,v in pairs(pad3players) do
  372.                 if hit.Username == v then
  373.                     found = true
  374.                     pad3 = pad3 - 1
  375.                     table.remove(pad3players, i)
  376.                     table.insert(pad1players, hit.Username)
  377.                     pad1 = pad1 + 1
  378.                     break
  379.                 end
  380.             end
  381.         end
  382.         if found == false then
  383.             table.insert(pad1players, hit.Username)
  384.             pad1 = pad1 + 1
  385.         end
  386.         updatevotes()
  387.         wait(0.1)
  388.     end
  389. end)
  390.  
  391. --Pad2--
  392. Workspace.Sensors.Sensor2.Touched:Connect(function(hit)
  393.     if hit:isA("Player") and mapselect == true then
  394.         hit.Position = Vector3.new(math.random(0, 6.5), 1, 14)
  395.         local found = false
  396.         if found == false then
  397.             for i,v in pairs(pad1players) do
  398.                 if hit.Username == v then
  399.                     found = true
  400.                     pad1 = pad1 - 1
  401.                     table.remove(pad1players, i)
  402.                     table.insert(pad2players, hit.Username)
  403.                     pad2 = pad2 + 1
  404.                     break
  405.                 end
  406.             end
  407.         end
  408.         if found == false then
  409.             for i,v in pairs(pad2players) do
  410.                 if hit.Username == v then
  411.                     found = true
  412.                     break
  413.                 end
  414.             end
  415.         end
  416.         if found == false then
  417.             for i,v in pairs(pad3players) do
  418.                 if hit.Username == v then
  419.                     found = true
  420.                     pad3 = pad3 - 1
  421.                     table.remove(pad3players, i)
  422.                     table.insert(pad2players, hit.Username)
  423.             pad2 = pad2 + 1
  424.                     break
  425.                 end
  426.             end
  427.         end
  428.         if found == false then
  429.             table.insert(pad2players, hit.Username)
  430.             pad2 = pad2 + 1
  431.         end
  432.         updatevotes()
  433.         wait(0.1)
  434.     end
  435. end)
  436.  
  437. --Pad3--
  438. Workspace.Sensors.Sensor3.Touched:Connect(function(hit)
  439.     if hit:isA("Player") and mapselect == true then
  440.         hit.Position = Vector3.new(math.random(0, 6.5), 1, 14)
  441.         local found = false
  442.         if found == false then
  443.             for i,v in pairs(pad1players) do
  444.                 if hit.Username == v then
  445.                     found = true
  446.                     pad1 = pad1 - 1
  447.                     table.remove(pad1players, i)
  448.                     table.insert(pad3players, hit.Username)
  449.                     pad3 = pad3 + 1
  450.                     break
  451.                 end
  452.             end
  453.         end
  454.         if found == false then
  455.             for i,v in pairs(pad2players) do
  456.                 if hit.Username == v then
  457.                     found = true
  458.                     pad2 = pad2 - 1
  459.                     table.remove(pad2players, i)
  460.                     table.insert(pad3players, hit.Username)
  461.             pad3 = pad3 + 1
  462.                     break
  463.                 end
  464.             end
  465.         end
  466.         if found == false then
  467.             for i,v in pairs(pad3players) do
  468.                 if hit.Username == v then
  469.                     found = true
  470.                     break
  471.                 end
  472.             end
  473.         end
  474.         if found == false then
  475.             table.insert(pad3players, hit.Username)
  476.             pad3 = pad3 + 1
  477.         end
  478.         updatevotes()
  479.         wait(0.1)
  480.     end
  481. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top