Advertisement
Guest User

GameHandler

a guest
Mar 29th, 2020
2,967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. local rStorage = game:GetService("ReplicatedStorage")
  2. local rEvents = rStorage:WaitForChild("RemoteEvents")
  3. local configs = rStorage:WaitForChild("Configs")
  4. local maps = rStorage:WaitForChild("Maps")
  5.  
  6. rEvents.AddPlayer.OnServerEvent:Connect(function(plr)
  7.     rEvents.AddPlayer:FireAllClients(plr)
  8. end)
  9.  
  10. rEvents.RemovePlayer.OnServerEvent:Connect(function(plr)
  11.     rEvents.RemovePlayer:FireAllClients(plr)
  12. end)
  13.  
  14. rEvents.AddVote.OnServerEvent:Connect(function(plr,name)
  15.     local map = rStorage.Votes:FindFirstChild(name)
  16.     if map then
  17.         map.Value = map.Value + 1
  18.     end
  19. end)
  20.  
  21. rEvents.RemoveVote.OnServerEvent:Connect(function(plr,name)
  22.     local map = rStorage.Votes:FindFirstChild(name)
  23.     if map then
  24.         map.Value = map.Value - 1
  25.     end
  26. end)
  27.  
  28. while true do
  29.     local timer = 15
  30.     repeat wait()
  31.         configs.Status.Value = "Intermission: ".. timer
  32.        
  33.         wait(1)
  34.         timer = timer - 1
  35.     until timer == 0
  36.     configs.Status.Value = "..."
  37.     wait(1)
  38.    
  39.     for i,v in pairs(maps:GetChildren()) do
  40.         local voteId = v:FindFirstChild("VoteId")
  41.         if voteId then
  42.             local intValue = Instance.new("IntValue",rStorage.Votes)
  43.             intValue.Name = v.Name
  44.             intValue.Value = 0
  45.            
  46.             rEvents.CreateVote:FireAllClients(v.Name,voteId.Value)
  47.         end
  48.     end
  49.    
  50.     timer = 10
  51.     repeat wait()
  52.         configs.Status.Value = "Map vote: ".. timer
  53.        
  54.         wait(1)
  55.         timer = timer - 1
  56.     until timer == 0
  57.     configs.Status.Value = "..."
  58.    
  59.     local map
  60.     local highest = 0
  61.     for i,v in pairs(rStorage.Votes:GetChildren()) do
  62.         if v:IsA("IntValue") then
  63.             local curMap = maps:FindFirstChild(v.Name)
  64.             if v.Value > highest and curMap then
  65.                 map = curMap
  66.             end
  67.         end
  68.     end
  69.    
  70.     if map then
  71.         configs.Status.Value = map.Name
  72.     else
  73.         map = maps:GetChildren()[1]
  74.         configs.Status.Value = map.Name
  75.     end
  76.    
  77.     rEvents.RemoveAllVotes:FireAllClients()
  78.    
  79.     for i,v in pairs(rStorage.Votes:GetChildren()) do
  80.         v:Destroy()
  81.     end
  82.    
  83.     wait(3)
  84.    
  85.     wait()
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement