Advertisement
Sungmingamerpro13

VotingSystem (LocalScript + 4 Votes)

May 13th, 2025
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.59 KB | None | 0 0
  1. -- Variables
  2.  
  3. local VoteRemotes = game.ReplicatedStorage.VoteRemotes
  4. local VoteValues = game.ReplicatedStorage.VoteValues
  5.  
  6. local hasVoted = false
  7. local VoteFrame = script.Parent
  8.  
  9. local function Vote(Button, Option)
  10.     if hasVoted == false then
  11.         hasVoted = true
  12.        
  13.         Button.Image = "rbxassetid://105874845643806"
  14.         wait(2)
  15.         Button.Image = "rbxassetid://101641611766368"
  16.         VoteRemotes.AddVoteEvent:FireServer(Option)
  17.     end
  18. end
  19.  
  20. -- Toggle Visible
  21.  
  22. VoteRemotes.ToggleVoteEvent.OnClientEvent:Connect(function(Value)
  23.    
  24.     if Value == true then
  25.         VoteFrame.Visible = true
  26.     elseif Value == false then
  27.         VoteFrame.Visible = false
  28.     end
  29. end)
  30.  
  31. VoteFrame.Ending1.Button.MouseButton1Click:Connect(function()
  32.     Vote(VoteFrame.Ending1.Button, 1)
  33. end)
  34.  
  35. VoteFrame.Ending2.Button.MouseButton1Click:Connect(function()
  36.     Vote(VoteFrame.Ending2.Button, 2)
  37. end)
  38.  
  39. VoteFrame.Ending3.Button.MouseButton1Click:Connect(function()
  40.     Vote(VoteFrame.Ending3.Button, 3)
  41. end)
  42.  
  43. VoteFrame.Ending4.Button.MouseButton1Click:Connect(function()
  44.     Vote(VoteFrame.Ending4.Button, 4)
  45. end)
  46.  
  47. -- Update Count --
  48.  
  49. VoteValues.Option1.Changed:Connect(function()
  50.     VoteFrame.Ending1.Votes.Text = VoteValues.Option1.Value
  51. end)
  52.  
  53. VoteValues.Option2.Changed:Connect(function()
  54.     VoteFrame.Ending2.Votes.Text = VoteValues.Option2.Value
  55. end)
  56.  
  57. VoteValues.Option3.Changed:Connect(function()
  58.     VoteFrame.Ending3.Votes.Text = VoteValues.Option3.Value
  59. end)
  60.  
  61. VoteValues.Option4.Changed:Connect(function()
  62.     VoteFrame.Ending4.Votes.Text = VoteValues.Option4.Value
  63. end)
  64.  
  65. while wait() do
  66.     VoteFrame.Status.Text = VoteValues.Status.Value
  67. end
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement