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 » Scripting Helpers
Home Search
 

Re: Help! This is probably an easy question to answer but...

Previous Thread :: Next Thread 
koala0226 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. koala0226
Joined: 17 Dec 2008
Total Posts: 1435
15 Jan 2014 06:46 PM
Okay that makes a little more sense...
Report Abuse
koala0226 is not online. 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
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
15 Jan 2014 07:01 PM
So you want the code to run until the key is pressed?
Report Abuse
koala0226 is not online. 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
Fireninja584 is not online. Fireninja584
Joined: 22 Jun 2012
Total Posts: 55
15 Jan 2014 07:16 PM
It makes sense a little for me
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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