HowToRoblox

VoteGuiHandler

May 19th, 2020
1,866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. local onVotingBegun = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("OnVotingBegun")
  2. local onVotingEnded = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("OnVotingEnded")
  3.  
  4. local onVoteMade = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("OnVoteMade")
  5.  
  6. local mapNamesFolder = game.ReplicatedStorage:WaitForChild("ChosenMapNames")
  7. local mapImagesFolder = game.ReplicatedStorage:WaitForChild("ChosenMapImages")
  8.  
  9. local mapVotesFolder = game.ReplicatedStorage:WaitForChild("MapVotes")
  10.  
  11.  
  12. local voteMap1Btn = script.Parent:WaitForChild("VoteMap1")
  13. local voteMap2Btn = script.Parent:WaitForChild("VoteMap2")
  14. local voteMap3Btn = script.Parent:WaitForChild("VoteMap3")
  15.  
  16. local mapName1 = script.Parent:WaitForChild("MapName1")
  17. local mapName2 = script.Parent:WaitForChild("MapName2")
  18. local mapName3 = script.Parent:WaitForChild("MapName3")
  19.  
  20. local mapImage1 = script.Parent:WaitForChild("MapImage1")
  21. local mapImage2 = script.Parent:WaitForChild("MapImage2")
  22. local mapImage3 = script.Parent:WaitForChild("MapImage3")
  23.  
  24. local votesMap1 = script.Parent:WaitForChild("VotesMap1")
  25. local votesMap2 = script.Parent:WaitForChild("VotesMap2")
  26. local votesMap3 = script.Parent:WaitForChild("VotesMap3")
  27.  
  28.  
  29. onVotingBegun.OnClientEvent:Connect(function()
  30.    
  31.     mapName1.Text = mapNamesFolder.Map1Name.Value
  32.     mapName2.Text = mapNamesFolder.Map2Name.Value
  33.     mapName3.Text = mapNamesFolder.Map3Name.Value
  34.    
  35.     mapImage1.Image = "rbxassetid://" .. mapImagesFolder.Map1Image.Value
  36.     mapImage2.Image = "rbxassetid://" .. mapImagesFolder.Map2Image.Value
  37.     mapImage3.Image = "rbxassetid://" .. mapImagesFolder.Map3Image.Value
  38.    
  39.     votesMap1.Text = "0"
  40.     votesMap2.Text = "0"
  41.     votesMap3.Text = "0"
  42.    
  43.     script.Parent.Visible = true
  44. end)
  45.  
  46. onVotingEnded.OnClientEvent:Connect(function()
  47.    
  48.     script.Parent.Visible = false
  49. end)
  50.  
  51.  
  52. onVoteMade.OnClientEvent:Connect(function()
  53.    
  54.     votesMap1.Text = #mapVotesFolder.Map1Votes:GetChildren()
  55.     votesMap2.Text = #mapVotesFolder.Map2Votes:GetChildren()
  56.     votesMap3.Text = #mapVotesFolder.Map3Votes:GetChildren()
  57. end)
  58.  
  59.  
  60. local function onVoteButtonPressed(mapNum)
  61.    
  62.     onVoteMade:FireServer(mapNum)
  63. end
  64.  
  65. voteMap1Btn.MouseButton1Click:Connect(function()
  66.     onVoteButtonPressed(1)
  67. end)
  68. voteMap2Btn.MouseButton1Click:Connect(function()
  69.     onVoteButtonPressed(2)
  70. end)
  71. voteMap3Btn.MouseButton1Click:Connect(function()
  72.     onVoteButtonPressed(3)
  73. end)
Add Comment
Please, Sign In to add comment