Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- NOTES:
- make sure the buttons are named Button1, Button2, and Button 3 like the ones below
- otherwise change it here
- ]]
- -- this one
- Button1 = game.workspace.Button1
- Button2 = game.workspace.Button2
- Button3 = game.workspace.Button3
- while true do
- --voting part
- table1 = {}
- table2 = {}
- table3 = {}
- voting = true
- print("start")
- Button1.Touched:Connect(function(hit)
- if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
- local char = hit.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local tableexist = false
- if #table1 > 0 then
- for b = 1, #table1, 1 do
- if table1[b] == plr.Name then
- tableexist = true
- end
- end
- end
- if #table2 > 0 then
- for b = 1, #table2, 1 do
- if table2[b] == plr.Name then
- table.remove(table2, b)
- end
- end
- end
- if #table3 > 0 then
- for b = 1, #table3, 1 do
- if table3[b] == plr.Name then
- table.remove(table3, b)
- end
- end
- end
- if tableexist == false then
- table1[#table1 + 1] = plr.Name
- end
- end
- end)
- Button2.Touched:Connect(function(hit)
- if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
- local char = hit.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local tableexist = false
- if #table2 > 0 then
- for b = 1, #table2, 1 do
- if table2[b] == plr.Name then
- tableexist = true
- end
- end
- end
- if #table1 > 0 then
- for b = 1, #table1, 1 do
- if table1[b] == plr.Name then
- table.remove(table1, b)
- end
- end
- end
- if #table3 > 0 then
- for b = 1, #table3, 1 do
- if table3[b] == plr.Name then
- table.remove(table3, b)
- end
- end
- end
- if tableexist == false then
- table2[#table2 + 1] = plr.Name
- end
- end
- end)
- Button3.Touched:Connect(function(hit)
- if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and voting == true then
- local char = hit.Parent
- local plr = game.Players:GetPlayerFromCharacter(char)
- local tableexist = false
- if #table3 > 0 then
- for b = 1, #table3, 1 do
- if table3[b] == plr.Name then
- tableexist = true
- end
- end
- end
- if #table2 > 0 then
- for b = 1, #table2, 1 do
- if table2[b] == plr.Name then
- table.remove(table2, b)
- end
- end
- end
- if #table1 > 0 then
- for b = 1, #table1, 1 do
- if table1[b] == plr.Name then
- table.remove(table1, b)
- end
- end
- end
- if tableexist == false then
- table3[#table3 + 1] = plr.Name
- end
- end
- end)
- wait(10)
- print("table 1: " .. #table1)
- print("table 2: " .. #table2)
- print("table 3: " .. #table3)
- voting = false
- winner = 0
- values = {
- {"1", #table1};
- {"2", #table2};
- {"3", #table3};
- }
- table.sort(values, function(a, b)
- if a[2] > b[2] then
- return true
- end
- end)
- if values[1][2] <= 0 then
- winner = math.random(1, 3)
- else
- winner = tonumber(values[1][1])
- end
- -- do a specific thing for the specific vote
- print(winner)
- --end of voting part
- wait(5)
- --do the rest of the game
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement