Alright so I redid the entire script into my own version to make sure I could get everything to work.
What you did wrong...
So you have it where when you click the brick, it turns the audio on and nothing to counter it if it's pressed again, it just keeps looping that audio and over-riding it or duplicating it. On-top of that, it will get very tedious to get the audio IDs all the time, i'd recommend just adding a folder named MusicFolder to Workspace and putting your sounds there and naming them what you want them to be named.
Look into these things.
I would recommend looking into if statements
Here's a video from AlvinBlox explaining if statements.
What you should improve on...
- Understanding if statements and audios.
- Learn about GUIs as they can be more easier to control.
- Look more into print() statements as they can help you determine what's not working.
What I did.
I rewrote the entire script so that way you could do the following...
- Have a folder for all your sounds instead of using IDs as that can become a hassle to do consistently.
- Made it so everything was organized
- Made it so it turned itself off and reset itself. To change its reseting of itself, remove the This resets the audio. line.
Script I made.
Brick = game.Workspace.MusicBrick
Music = game.Workspace.MusicFolder
ClickDetector = Brick.ClickDetector
function PlayMusic()
if Music.MULE.Playing == false then
Music.MULE.Playing = true
print(1)
else
Music.MULE.Playing = false
Music.MULE.TimePosition = 0
print(2)
end
end
ClickDetector.MouseClick:Connect(PlayMusic)
print("Entire Script Working")
1 comment
ClickDetector can be server sided so there is no need for remotes.