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 » Scripting Helpers
Home Search
 

Re: Dynamic Script switch on and off...

Previous Thread :: Next Thread 
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
20 Feb 2014 08:27 AM
Please fix the script below

game.Workspace.Switch=Switch
game.Workspace.Light.SpotLight=Light
Debounce=false
function OnClick1(Lighton)
debounce=false
Light.Enabled=true
end
Script.Parent.OnTouch:Connect(OnClick1)
function OnClick2(Lightoff)
debounce=true
Light.Enabled=false
end
Script.Parent.Click:connect(OnClick2)
----------------------------------------------------
I have put a click detector in the Switch
Report Abuse
inspiredArbitrator is not online. inspiredArbitrator
Joined: 13 Jan 2008
Total Posts: 6447
20 Feb 2014 08:29 AM
Switch = Workspace.Switch --The left operand is the variable name
Light = Workspace.Light.SpotLight

local deb = false

function OnClick()
if deb then return end
deb = true
Light.Enabled = not Light.Enabled
wait(.5)
deb = false
end
Switch.ClickDetector.MouseClick:connect(OnClick)
Report Abuse
truefire2 is not online. truefire2
Joined: 04 Jul 2010
Total Posts: 5330
20 Feb 2014 08:31 AM
So disorganised. Why do you have one with an OnTouch and the other with an OnClicked?

Also, that is not how connection lines work.
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
20 Feb 2014 08:38 AM
The script works perfectly but what does the
if deb then return end mean?
Report Abuse
truefire2 is not online. truefire2
Joined: 04 Jul 2010
Total Posts: 5330
20 Feb 2014 08:47 AM
To stop it happening too many times.
Report Abuse
KOzero is not online. KOzero
Joined: 11 May 2010
Total Posts: 1411
20 Feb 2014 09:13 AM
Ok
Report Abuse
inspiredArbitrator is not online. inspiredArbitrator
Joined: 13 Jan 2008
Total Posts: 6447
20 Feb 2014 10:08 AM
The line 'if deb then return end' can be expanded into three lines like so:

if deb then
return
end

The empty return simply returns nothing, but what it does do is exit the function.

Since 'deb' is a boolean value, it is either true or false. In this instance, I chose to set it to true when active and false when inactive.

The wait() a few lines down is the minimum amount of time before the button can be clicked again.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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