Advertisement
4zx16

Music Gui (Mute/Unmute)

Nov 21st, 2021 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. --[[
  2.  || 📜 AUTHOR: @4zx16 || MUTE/UNMUTE
  3. ]]
  4. local muteButton = script.Parent
  5. local music = game:GetService("ReplicatedStorage").Music
  6. local currentTrack = game:GetService("ReplicatedStorage").CurrentTrack
  7. local muted = false
  8.  
  9. muteButton.MouseButton1Click:Connect(function()
  10.     local nowPlaying = music[currentTrack.Value]
  11.    
  12.     nowPlaying.Volume = muted and 0.5 or 0
  13.    
  14.     muted = not muted
  15. end)
  16.  
  17. currentTrack:GetPropertyChangedSignal("Value"):Connect(function()
  18.     local nowPlaying = music[currentTrack.Value]
  19.    
  20.     if muted == true then
  21.         nowPlaying.Volume = 0
  22.     elseif muted == false then
  23.         nowPlaying.Volume = 0.5
  24.     end
  25. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement