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: Escaping a for loop?

Previous Thread :: Next Thread 
3DShooter is not online. 3DShooter
Joined: 04 Aug 2010
Total Posts: 976
07 Aug 2012 07:08 AM
Hey, I have this loop, it's supposed to add a bytecode to a table, provided the bytecode isn't already there, however I don't know how to escape a loop once the bytecode has been found.

Here's the script.

1| Mouse.KeyDown:connect(function(Key)
2| for i = 0, #Keys do
3| if Keys[i] == string.byte(Key) then
4| --found the key, stop.
5| else
6| table.insert(Keys, string.byte(Key))
7| end
8| end
9| print(string.byte(Key).." was inserted into Keys")
10| end)

What do I add into line 4?
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
07 Aug 2012 07:10 AM
break
Report Abuse
3DShooter is not online. 3DShooter
Joined: 04 Aug 2010
Total Posts: 976
07 Aug 2012 07:11 AM
that's the word! I couldn't find it :| I tried Quit, Escape, Exit :D
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
07 Aug 2012 07:12 AM
Does it even work? I can't see "Keys" defined, until it comes to the for loop check.
Also there are different ways to do it. You could use a while loop or repeat or just break the loop or also, if necessary, disconnect the event.
Report Abuse
3DShooter is not online. 3DShooter
Joined: 04 Aug 2010
Total Posts: 976
07 Aug 2012 07:20 AM
Keys is defined as an empty array at the start of the script, not shown in this particular segment, this is just a keyDown event.
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
07 Aug 2012 07:21 AM
Already thought of that.
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