Advertisement
OnFireRobloxScriptin

Mute/Unmute Music Script

Dec 15th, 2023 (edited)
2,473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. --//Script should be under the StarterGui
  2. --//Variables
  3. local button = script.Parent --Button Variable
  4. local music = workspace:WaitForChild("Relaxed Scene") --Music Variable, replace "Relaxed Scene" with the name of your music
  5. local red = BrickColor.new("Really red") --Variable for color red
  6. local green = BrickColor.new("Lime green") --Variable for color green
  7. local playing = true --Boolean Value for if music is playing
  8.  
  9. --//Click to Mute/Unmute
  10. button.MouseButton1Click:Connect(function() --Script runs when button is clicked
  11.     if playing then --If Boolean "Playing" is true then
  12.         playing = false --Set Boolean "Playing" to false
  13.         button.BackgroundColor = red --Change background color to Red
  14.         button.Text = "Off" --Change text to "Off"
  15.         music.Playing = false --Stop playing the music
  16.     elseif not playing then --If Boolean "Playing" is false then
  17.         playing = true --Set Boolean "Playing" to true
  18.         button.BackgroundColor = green --Change background color to Green
  19.         button.Text = "On" --Change text to "On"
  20.         music.Playing = true --Start playing the music
  21.     end
  22. end)
  23.  
  24. --NOTE:
  25. --This Script does not include a cooldown. If you would like to add one, you can watch the full tutorial here: (It also shows you how to set this script up!)
  26. --https://youtu.be/kpBJFDxSXik?si=nD_tMlIX-3EbiPlq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement