I have some music with a script like this:
01 | local sound 1 = 949583914 |
02 | local sound 2 = 918984470 |
03 | local sound 3 = 390846973 |
04 | local music = script.Parent |
05 |
06 |
07 | while true do |
08 | wait() |
09 | music.SoundId = "rbxassetid://" ..sound 1 |
10 | music:Play() |
11 | music.Ended:wait() |
12 | wait() |
13 | music.SoundId = "rbxassetid://" ..sound 2 |
14 | music:Play() |
15 | music.Ended:wait() |
And I tried doing this:
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | script.Parent.Parent.Parent.Parent.Parent.Music.Volume = 0 |
3 | end ) |
I don't know what I did wrong. You might not even be able to change the volume like that. I need it to be fully local too.
1 | local Button = script.Parent -- Or where the button is |
2 | local Music = script.Parent.Parent:WaitForChild( 'Music' ) -- Or where the music is |
3 |
4 | Button.MouseButton 1 Click:connect( function () |
5 | Music.Playing = not Music.Playing -- If playing is true then it makes playing false and reversed |
6 | end ) |
Should explain itself, if you don't understand it, just ask :)
01 | local Button = script.Parent |
02 | Music = script.Parent.Parent:WaitForChild( "Music" ) |
03 |
04 | Button.MouseButton 1 Down:Connect( function () |
05 | if Music.Playing then -- If the music is playing... |
06 | Music.Playing = not Music.Playing -- Or Music:Pause() |
07 | end |
08 | if not Music.Playing then -- If the music is not playing... |
09 | Music.Playing = true -- Keep playing it |
10 | end |
11 | end ) |
Try that.