SteamRail
|
  |
| Joined: 26 Jul 2008 |
| Total Posts: 1147 |
|
|
| 14 Aug 2014 11:52 PM |
So I got the script to work by clicking the left mouse button on the TextButton so it would play the music. Well that's great and all but now I need a way to turn it off with same button. I got it to work with the right mouse button but I want to be able to toggle on/off with the same button, how could I do this?
This is what I got:
function Music() script.Parent.BackGround:play() end
script.Parent.MouseButton1Click:connect(Music)
function MusicOff() script.Parent.BackGround:stop() end
script.Parent.MouseButton2Click:connect(MusicOff)
|
|
|
| Report Abuse |
|
|
SteamRail
|
  |
| Joined: 26 Jul 2008 |
| Total Posts: 1147 |
|
| |
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 19 Aug 2014 08:02 PM |
on = false
function turnOn() if (on == false) then on = true --do stuff for turning it on end end
function turnOff() if (on == true) then on = false --do stuff for turning it off end end
Button.MouseButton1Click:connect(turnOn) Button.MouseButton1Click:connect(turnOff) |
|
|
| Report Abuse |
|
|
4567777
|
  |
| Joined: 13 Jul 2013 |
| Total Posts: 128 |
|
|
| 19 Aug 2014 08:03 PM |
on=false function music() on = not on if(on)then script.Parent.BackGround:play() else script.Parent.BackGround:stop() end end
script.Parent.MouseButton1Click:connect(music) |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 19 Aug 2014 08:05 PM |
| Oh wow, I derped. Don't know why I used 2 functions... |
|
|
| Report Abuse |
|
|
SteamRail
|
  |
| Joined: 26 Jul 2008 |
| Total Posts: 1147 |
|
| |
|