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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 5330 |
|
|
| 20 Feb 2014 08:47 AM |
| To stop it happening too many times. |
|
|
| Report Abuse |
|
|
KOzero
|
  |
| Joined: 11 May 2010 |
| Total Posts: 1411 |
|
| |
|
|
| 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 |
|
|