|
| 26 Jun 2015 10:44 AM |
So, I tried making a loop start when you press a certain key. And to cancel the loop, you'd have to press another key. But this didn't work. Why?
local Var = true
Mouse.KeyDown:connect(function(Key)
if Key == "q" then while Var do
print("looping")
wait() end end end)
Mouse.KeyDown:connect(function(Key)
if Key == "e" then
Var = false
end end) |
|
|
| Report Abuse |
|
|
|
| 26 Jun 2015 10:46 AM |
Well when you pressed q, it began the loop, which is a while loop that goes on forever, basically it can't read what's after it :c
Do something like
UIS.InputBegan:connect(function(inputObject) if inputObject.KeyCode == Enum.KeyCode.Q then var = true end end)
UIS.InputBegan:connect(function(inputObject) if inputObject.KeyCode == Enum.KeyCode.E then var = false end end)
while var do wait() print("loop da looping") end |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 26 Jun 2015 10:51 AM |
| Wreckerbuster67, stop misinforming people. OP's script works just fine. |
|
|
| Report Abuse |
|
|
|
| 26 Jun 2015 10:51 AM |
| It worked fine for me. Maybe you might have pressed "q" more times than needed. |
|
|
| Report Abuse |
|
|
|
| 26 Jun 2015 10:53 AM |
| Nvm then, couldn't test, studio is crashing for some reason. Anyways, I'd still suggest using UIS. |
|
|
| Report Abuse |
|
|