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: Help With On/ off Script?

Previous Thread :: Next Thread 
greencomander30 is not online. greencomander30
Joined: 23 May 2011
Total Posts: 50
04 Mar 2017 09:59 AM
I've been trying to write an on/ off script using a click detector that activates/ deactivates a ParticleEmitter. But, I can't seem to figure out how to make it work. Can anyone help me? I'll post what I have below, hopefully Roblox won't censor.

script.Parent.ClickDetector.MouseClick:connect(onClicked)
local sm = script.Parent.Parent.smoke

local isOn = false
script.Parent.Button.Detect.MouseClick:connect(function()
if On==false then
isOn = true
sm.ParticleEmitter.Enabled = true
On=true
elseif On==true then
isOn = false
sm.ParticleEmitter.Enabled = false
On=false
end
Report Abuse
iiJameul is not online. iiJameul
Joined: 11 Feb 2017
Total Posts: 85
04 Mar 2017 10:05 AM
1) You have not explained what On is you have explained to the server what IsOn is but not On.

Use local On = false

2)I do not see the need to have On and IsOn in the script.

3) ClickDetectors are buggy.

4) you should use;

Script.Parent.MouseClick:Connect(function()
sm.Enabled = not sm.Enabled
End

68% of people cannot script that 1% is me.

Report Abuse
greencomander30 is not online. greencomander30
Joined: 23 May 2011
Total Posts: 50
04 Mar 2017 10:15 AM
Ok so along with your changes, I tried to add some aswell, but they still do not work. What am I doing wrong?

Script.Parent.MouseClick:Connect(function()
sm.Enabled = not sm.Enabled
local sm = script.Parent.Parent.smoke

local On = false
script.Parent.Button.Detect.MouseClick:connect(function()
if On==false then
sm.ParticleEmitter.Enabled = true
elseif On==true then
sm.ParticleEmitter.Enabled = false

end
Report Abuse
FloweryMonkeyboy5 is not online. FloweryMonkeyboy5
Joined: 19 Sep 2012
Total Posts: 528
04 Mar 2017 11:17 AM
You know what is going wrong?

The fact that you call to a variable before assigning it:
sm.Enabled = not sm.Enabled
local sm = script.Parent.Parent.smoke
Report Abuse
greencomander30 is not online. greencomander30
Joined: 23 May 2011
Total Posts: 50
04 Mar 2017 11:18 AM
so how do I fix that?


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
04 Mar 2017 11:18 AM
I'm also confused why he's using the 'On' variable if he's aware that the 'not' logical operator exists.


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