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: How do I make it so this script does not mess up?

Previous Thread :: Next Thread 
Stewie140 is not online. 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 is not online. 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
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
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
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
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 is not online. Stewie140
Joined: 24 Dec 2010
Total Posts: 212
03 Aug 2015 03:15 PM
wow that was fast! thanks guys :)
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