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
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
| |
|