Advertisement
saturnsolar

RevealScript (Map Voting GUI) | ROBLOX Studio

Apr 24th, 2020
8,401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. local rep = game:GetService("ReplicatedStorage")
  2. local boolean = rep:WaitForChild("Booleans"):WaitForChild("RevealVotes")
  3. local variables = rep:WaitForChild("Variables")
  4. local voteChoice1 = variables:FindFirstChild("VoteChoice1")
  5. local voteChoice2 = variables:FindFirstChild("VoteChoice2")
  6. local voteChoice3 = variables:FindFirstChild("VoteChoice3")
  7. local winner = variables:FindFirstChild("Winner")
  8.  
  9.  
  10. boolean:GetPropertyChangedSignal("Value"):Connect(function()
  11.     if boolean.Value == true then
  12.         --release the bees!
  13.         local players = game:GetService("Players"):GetPlayers()
  14.        
  15.         for x, player in pairs(players) do
  16.             if player.voted then
  17.                 player.voted.Value = true
  18.             end
  19.             wait()
  20.         end
  21.         winner.Value = nil
  22.         local mapvotes = {}
  23.         local biggestone
  24.        
  25.         table.insert(mapvotes,voteChoice1.Value)
  26.         wait()
  27.         table.insert(mapvotes,voteChoice2.Value)
  28.         wait()
  29.         table.insert(mapvotes,voteChoice3.Value)
  30.        
  31.         table.sort(mapvotes)
  32.        
  33.         local biggest = tonumber(mapvotes[#mapvotes])
  34.        
  35.         if biggest == voteChoice1.Value then
  36.             biggestone = variables:FindFirstChild("Choice1")
  37.         end
  38.         if biggest == voteChoice2.Value then
  39.             biggestone = variables:FindFirstChild("Choice2")
  40.         end
  41.         if biggest == voteChoice3.Value then
  42.             biggestone = variables:FindFirstChild("Choice3")
  43.         end
  44.         if biggestone then
  45.         winner.Value = biggestone
  46.         end
  47.     else
  48.         local players = game:GetService("Players"):GetPlayers()
  49.        
  50.         for x, player in pairs(players) do
  51.             if player.voted then
  52.                 player.voted.Value = false
  53.             end
  54.             wait()
  55.         end
  56.        
  57.         voteChoice1.Value = 0
  58.         voteChoice2.Value = 0
  59.         voteChoice3.Value = 0
  60.     end
  61. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement