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
 

Why wouldn't something like this work?

Previous Thread :: Next Thread 
DoctorHelix is not online. DoctorHelix
Joined: 05 May 2015
Total Posts: 303
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
Wreckerbuster67 is not online. Wreckerbuster67
Joined: 29 Jul 2012
Total Posts: 1144
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 is not online. 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
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
26 Jun 2015 10:51 AM
It worked fine for me. Maybe you might have pressed "q" more times than needed.
Report Abuse
Wreckerbuster67 is not online. Wreckerbuster67
Joined: 29 Jul 2012
Total Posts: 1144
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
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