Advertisement
Sungmingamerpro13

FoodsScript(LocalScript)

Mar 5th, 2023 (edited)
944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.18 KB | None | 0 0
  1. --- Variables ---
  2.  
  3. local ToggleVoteEvent = game.ReplicatedStorage.FoodsSystem.ToggleVoteEvent
  4. local AddVoteEvent = game.ReplicatedStorage.FoodsSystem.AddVoteEvent
  5. local Button1 = script.Parent.FoodButton1
  6. local Button2 = script.Parent.FoodButton2
  7.  
  8. local HasVoted = false
  9.  
  10. local VoteFrame = script.Parent
  11.  
  12. local Option1 = game.ReplicatedStorage.FoodsSystem.Food1
  13. local Option2 = game.ReplicatedStorage.FoodsSystem.Food2
  14.  
  15.  
  16. --- Toggle Visible ---
  17.  
  18. ToggleVoteEvent.OnClientEvent:Connect(function(Value)
  19.    
  20.     if Value == true then
  21.        
  22.         VoteFrame.Visible = true
  23.        
  24.     elseif Value == false then
  25.        
  26.         VoteFrame.Visible = false
  27.        
  28.     end
  29. end)
  30.  
  31. --- Add Vote ---
  32.  
  33. local function Vote(Button, Option)
  34.     if HasVoted == false then
  35.         HasVoted = true
  36.        
  37.         Button.BackgroundColor3 = Color3.new(0, 255, 255)
  38.         AddVoteEvent:FireServer(Option)
  39.     end
  40. end
  41.  
  42. Button1.MouseButton1Click:Connect(function()
  43.     Vote(Button1, 1)
  44. end)
  45.  
  46. Button2.MouseButton1Click:Connect(function()
  47.     Vote(Button2, 1)
  48. end)
  49.  
  50. --- Update Count ---
  51.  
  52. Option1.Changed:Connect(function()
  53.     Button1.VoteCount.Text = Option1.Value
  54. end)
  55.  
  56. Option2.Changed:Connect(function()
  57.     Button2.VoteCount.Text = Option2.Value
  58. end)
  59.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement