koala0226
|
  |
| Joined: 17 Dec 2008 |
| Total Posts: 1435 |
|
|
| 15 Jan 2014 06:25 PM |
I'm trying to repeat this function until the key isn't pushed down anymore but I don't know how to...I feel like it'll be an easy fix like instead of lower its higher or something like that -_- This is the section that deals with this...
local function onKeyDown(key) if (key~=nil) then key:lower() if (key == "w") then BV.velocity = Vector3.new(100,0,0) ll.DesiredAngle = 0.5 la.DesiredAngle = -0.5 ra.DesiredAngle = 0.5 rl.DesiredAngle = -0.5 wait(1) ll.DesiredAngle = -0.5 la.DesiredAngle = 0.5 ra.DesiredAngle = -0.5 rl.DesiredAngle = 0.5 repeat until
|
|
|
| Report Abuse |
|
|
nathen35
|
  |
| Joined: 10 Feb 2011 |
| Total Posts: 73 |
|
|
| 15 Jan 2014 06:30 PM |
"While true do" should work if you add it like this
while true do -- Make it repeat local function onKeyDown(key) if (key~=nil) then key:lower() if (key == "w") then BV.velocity = Vector3.new(100,0,0) ll.DesiredAngle = 0.5 la.DesiredAngle = -0.5 ra.DesiredAngle = 0.5 rl.DesiredAngle = -0.5 wait(1) ll.DesiredAngle = -0.5 la.DesiredAngle = 0.5 ra.DesiredAngle = -0.5 rl.DesiredAngle = 0.5 |
|
|
| Report Abuse |
|
|
koala0226
|
  |
| Joined: 17 Dec 2008 |
| Total Posts: 1435 |
|
|
| 15 Jan 2014 06:32 PM |
| No that didn't really help it..Didn't seem to do anything really :o |
|
|
| Report Abuse |
|
|
Thaeh
|
  |
| Joined: 05 Feb 2011 |
| Total Posts: 7685 |
|
|
| 15 Jan 2014 06:38 PM |
Mouse.KeyUp:connect(function(´Key) if Key == "a" then Active = false end)
Mouse.KeyDown:connect(function(Key) if Key == "a" and not Active then Active = true repeat print("Hi.") until not Active end end) |
|
|
| Report Abuse |
|
|
koala0226
|
  |
| Joined: 17 Dec 2008 |
| Total Posts: 1435 |
|
|
| 15 Jan 2014 06:46 PM |
| Okay that makes a little more sense... |
|
|
| Report Abuse |
|
|
koala0226
|
  |
| Joined: 17 Dec 2008 |
| Total Posts: 1435 |
|
|
| 15 Jan 2014 06:55 PM |
If it helps I'll add in the full script:
mouse = game.Players.LocalPlayer:GetMouse( ) JaegerOn = game.Players.LocalPlayer.Character:FindFirstChild("JO").Value ll = game.Workspace.Modelz:FindFirstChild("Left Leg") la = game.Workspace.Modelz:FindFirstChild("Left Arm") ra = game.Workspace.Modelz:FindFirstChild("Right Arm") rl = game.Workspace.Modelz:FindFirstChild("Right Leg") BV = game.Workspace.Modelz.Main.BodyVelocity
local function onKeyDown(key) if (key~=nil) then key:lower() if (key == "w")and JaegerOn == true then BV.velocity = Vector3.new(100,0,0) ll.DesiredAngle = 0.5 la.DesiredAngle = -0.5 ra.DesiredAngle = 0.5 rl.DesiredAngle = -0.5 print("w") wait(1) ll.DesiredAngle = -0.5 la.DesiredAngle = 0.5 ra.DesiredAngle = -0.5 rl.DesiredAngle = 0.5 repeat until mouse:Button1Down() elseif (key == "s")and JaegerOn == true then BV.velocity = Vector3.new(-100,0,0) ll.DesiredAngle = 0.5 la.DesiredAngle = -0.5 ra.DesiredAngle = 0.5 rl.DesiredAngle = -0.5 wait(1) ll.DesiredAngle = -0.5 la.DesiredAngle = 0.5 ra.DesiredAngle = -0.5 rl.DesiredAngle = 0.5 repeat until keyUp("s") else BV.velocity = Vector3.new(0,0,0) ll.DesiredAngle = 0 la.DesiredAngle = 0 ra.DesiredAngle = 0 rl.DesiredAngle = 0 end end end
mouse.KeyDown:connect(onKeyDown) |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2014 07:01 PM |
| So you want the code to run until the key is pressed? |
|
|
| Report Abuse |
|
|
koala0226
|
  |
| Joined: 17 Dec 2008 |
| Total Posts: 1435 |
|
|
| 15 Jan 2014 07:15 PM |
I would like to run this section, if (key == "w")and JaegerOn == true then BV.velocity = Vector3.new(100,0,0) ll.DesiredAngle = 0.5 la.DesiredAngle = -0.5 ra.DesiredAngle = 0.5 rl.DesiredAngle = -0.5 wait(1) ll.DesiredAngle = -0.5 la.DesiredAngle = 0.5 ra.DesiredAngle = -0.5 rl.DesiredAngle = 0.5
,to loop until the button ("w") is no longer pushed To put this in perspective...This is a giant mech that has limbs like a robloxian with the parts that are changing their desired angle to simulate walking. I need it to cycle between the two parts seperated by the wait(1) but right now it just goes through that motion once and just continues to move that direction due to the bodyvelocity(the only way to make it move) |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2014 07:16 PM |
| It makes sense a little for me |
|
|
| Report Abuse |
|
|