Stewie140
|
  |
| Joined: 24 Dec 2010 |
| Total Posts: 212 |
|
|
| 03 Aug 2015 03:09 PM |
Hello. I am a beginner to scripting (ish) and I was wondering if a train touches the activate brick to activate an alarm in a depot multiple times, can I make it so it does not activate the script again when the train touches it once? Thanks!
Script:
function OnTouch() script.Parent.Parent.IsOn.Value = true wait(3) script.Parent.Parent.IsOn.Value = false end script.Parent.Touched:connect(OnTouch) |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 03 Aug 2015 03:09 PM |
wiki.roblox.com/index.php?title=Debounce
u sicko! |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2015 03:12 PM |
local debounce = false script.Parent.Touched:connect(function(part) if debounce == true then debounce = false script.Parent.Parent.IsOn.Value = true wait(3) script.Parent.Parent.IsOn.Value = false end debounce = false end)
|
|
|
| Report Abuse |
|
|
|
| 03 Aug 2015 03:13 PM |
lol sorry wrong way
local debounce = false script.Parent.Touched:connect(function(part) if debounce == false then debounce = true script.Parent.Parent.IsOn.Value = true wait(3) script.Parent.Parent.IsOn.Value = false end debounce = false end)
this instead
|
|
|
| Report Abuse |
|
|
Stewie140
|
  |
| Joined: 24 Dec 2010 |
| Total Posts: 212 |
|
|
| 03 Aug 2015 03:15 PM |
| wow that was fast! thanks guys :) |
|
|
| Report Abuse |
|
|