Advertisement
vendaskOfficial

democracy

Sep 19th, 2020
1,728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.22 KB | None | 0 0
  1. --[[
  2. NOTES:
  3. make sure the buttons are named Button1, Button2, and Button 3 like the ones below
  4. otherwise change it here
  5. ]]
  6.  
  7. --                      this one
  8. Button1 = game.workspace.Button1
  9. Button2 = game.workspace.Button2
  10. Button3 = game.workspace.Button3
  11.  
  12. while true do
  13.  
  14.     --voting part
  15.    
  16.     table1 = {}
  17.     table2 = {}
  18.     table3 = {}
  19.  
  20.     voting = true
  21.    
  22.     print("start")
  23.  
  24.     Button1.Touched:Connect(function(hit)
  25.         if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
  26.             local char = hit.Parent
  27.             local plr = game.Players:GetPlayerFromCharacter(char)
  28.             local tableexist = false
  29.             if #table1 > 0 then
  30.                 for b = 1, #table1, 1 do
  31.                     if table1[b] == plr.Name then
  32.                         tableexist = true
  33.                     end
  34.                 end
  35.             end
  36.             if #table2 > 0 then
  37.                 for b = 1, #table2, 1 do
  38.                     if table2[b] == plr.Name then
  39.                         table.remove(table2, b)
  40.                     end
  41.                 end
  42.             end
  43.             if #table3 > 0 then
  44.                 for b = 1, #table3, 1 do
  45.                     if table3[b] == plr.Name then
  46.                         table.remove(table3, b)
  47.                     end
  48.                 end
  49.             end
  50.             if tableexist == false then
  51.                 table1[#table1 + 1] = plr.Name
  52.             end
  53.         end
  54.     end)
  55.     Button2.Touched:Connect(function(hit)
  56.         if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
  57.             local char = hit.Parent
  58.             local plr = game.Players:GetPlayerFromCharacter(char)
  59.             local tableexist = false
  60.             if #table2 > 0 then
  61.                 for b = 1, #table2, 1 do
  62.                     if table2[b] == plr.Name then
  63.                         tableexist = true
  64.                     end
  65.                 end
  66.             end
  67.             if #table1 > 0 then
  68.                 for b = 1, #table1, 1 do
  69.                     if table1[b] == plr.Name then
  70.                         table.remove(table1, b)
  71.                     end
  72.                 end
  73.             end
  74.             if #table3 > 0 then
  75.                 for b = 1, #table3, 1 do
  76.                     if table3[b] == plr.Name then
  77.                         table.remove(table3, b)
  78.                     end
  79.                 end
  80.             end
  81.             if tableexist == false then
  82.                 table2[#table2 + 1] = plr.Name
  83.             end
  84.         end
  85.     end)
  86.     Button3.Touched:Connect(function(hit)
  87.         if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
  88.             local char = hit.Parent
  89.             local plr = game.Players:GetPlayerFromCharacter(char)
  90.             local tableexist = false
  91.             if #table3 > 0 then
  92.                 for b = 1, #table3, 1 do
  93.                     if table3[b] == plr.Name then
  94.                         tableexist = true
  95.                     end
  96.                 end
  97.             end
  98.             if #table2 > 0 then
  99.                 for b = 1, #table2, 1 do
  100.                     if table2[b] == plr.Name then
  101.                         table.remove(table2, b)
  102.                     end
  103.                 end
  104.             end
  105.             if #table1 > 0 then
  106.                 for b = 1, #table1, 1 do
  107.                     if table1[b] == plr.Name then
  108.                         table.remove(table1, b)
  109.                     end
  110.                 end
  111.             end
  112.             if tableexist == false then
  113.                 table3[#table3 + 1] = plr.Name
  114.             end
  115.         end
  116.     end)
  117.  
  118.     wait(10)
  119.  
  120.     print("table 1: " .. #table1)
  121.     print("table 2: " .. #table2)
  122.     print("table 3: " .. #table3)
  123.  
  124.     voting = false
  125.  
  126.     winner = 0
  127.  
  128.     values = {
  129.         {"1", #table1};
  130.         {"2", #table2};
  131.         {"3", #table3};
  132.     }
  133.  
  134.     table.sort(values, function(a, b)
  135.         if a[2] > b[2] then
  136.             return true
  137.         end
  138.     end)
  139.  
  140.     if values[1][2] <= 0 then
  141.         winner = math.random(1, 3)
  142.     else
  143.         winner = tonumber(values[1][1])
  144.     end
  145.  
  146.     -- do a specific thing for the specific vote
  147.    
  148.     print(winner)
  149.  
  150.     --end of voting part
  151.    
  152.     wait(5)
  153.  
  154.     --do the rest of the game
  155.    
  156. end
  157.  
  158.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement