|
| 07 Dec 2015 06:55 PM |
script.Parent.MouseButton1Down:connect(function() local enabled = true if not enabled then enabled = true script.Parent.W:Play() else enabled = false script.Parent.W:Stop() end end)
I'm trying to make music play when I click it, but when I click it again I want it to stop playing, any help?
Thanks! |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2015 06:58 PM |
script.Parent.MouseButton1Click:connect(function() enabled = false if not enabled then enabled = true script.Parent.W:Play() elseif enabled then enabled = false script.Parent.W:Stop() end end)
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2015 06:59 PM |
| Your problem is the placement of your enabled variable. This must be outside of the event! Every time you fire MouseButton1Down, your variable is being set back to true. If you create the variable before the event, you'll have no problem. |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2015 07:01 PM |
enabled = false
script.Parent.MouseButton1Click:connect(function() if not enabled then enabled = true script.Parent.W:Play() elseif enabled then enabled = false script.Parent.W:Stop() end end)
amend to previous script, thanks to alphawolvess |
|
|
| Report Abuse |
|
|
| |
|