|
| 06 Feb 2014 07:57 PM |
| So I have made a script that has a loop and a bar drain that activates when I hold a button. Though when I release the button it keeps playing the loop. I want the bar to stop draining when I release the key I press. I need to know how to break loops on KeyUp. |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 07:59 PM |
keydown keyisdown = true repeat whatever until keyisdown = false
keyup keyisdown = false |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2014 08:06 PM |
| Not very helpful. Can you please like describe, your just telling random stuff that is not even in the right case. |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 08:09 PM |
i just gave you a perfect outline for your script
|
|
|
| Report Abuse |
|
|
|
| 06 Feb 2014 08:22 PM |
| I already have a script, I just need a way to stop the loop when keyup. |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 08:24 PM |
at the end of your loop do a keyup function, check if it's the right key if it is do
break |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 06 Feb 2014 08:32 PM |
localscript plz
down = true player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key == "y" and down = true then prunt("y is up") down = true mouse.KeyUp:connect(function(key) if key == "y" then down = false |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 06 Feb 2014 08:33 PM |
down = true player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key == "y" and down = true then prunt("y is up") down = true mouse.KeyUp:connect(function(key) if key == "y" then down = false end end end) end)
:o
|
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 08:39 PM |
kev what
if anything
down = false player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key == "y" and not down then prunt("y is down") down = true repeat dostuff() wait() until not down end end) mouse.KeyUp:connect(function(key) if key == "y" then down = false end)
or do this
player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key == "y" then prunt("y is down") while true do wait() dostuff() mouse.KeyUp:connect(function(ke) if ke == "y" then break end end) end end) |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 06 Feb 2014 08:40 PM |
down = true player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key == "y" and down == true then print("y is up") down = true mouse.KeyUp:connect(function(key) if key == "y" then down = false end end end) end)
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Feb 2014 08:41 PM |
I like this way the best:
local player = Game.Players.LocalPlayaer local mouse = player:GetMouse() local down = false
mouse.KeyDown:connect(function(key) if k == "y" then down = true end end) mouse.KeyUp:connect(function(key) if k == "y" then down = false end end)
while wait() do if down then --etc end end |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 08:43 PM |
| problem with that is that you're unnecessarily making the computer check every wait(). much better to do my first solution |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 08:44 PM |
| also i've actually had problems with that method |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Feb 2014 08:45 PM |
| while loops don't lag if you do nothing but wait. Your way is glitchy, if someone plugs in two keyboards then your way will screw everything up. It's better to be safe. |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2014 08:46 PM |
| None of these work for the script I made. |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
| |
|
|
| 06 Feb 2014 09:07 PM |
| I ma remaking my scripts to help better adjust with my stuff. I have values and gui and stuff and your scripts can't integrate it. Thanks for all your help guys. |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 06 Feb 2014 09:09 PM |
| give us your script and let us do it for you... |
|
|
| Report Abuse |
|
|