generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: I need help please!

Previous Thread :: Next Thread 
TheBuilderGames is not online. TheBuilderGames
Joined: 28 Mar 2013
Total Posts: 211
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
modularVoid is not online. modularVoid
Joined: 05 Dec 2015
Total Posts: 32
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
alphawolvess is not online. alphawolvess
Joined: 04 Jul 2012
Total Posts: 354
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
modularVoid is not online. modularVoid
Joined: 05 Dec 2015
Total Posts: 32
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
TheBuilderGames is not online. TheBuilderGames
Joined: 28 Mar 2013
Total Posts: 211
07 Dec 2015 07:09 PM
Thanks!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image