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
 

For Loop broken, help please?

Previous Thread :: Next Thread 
ultralegomaster5096 is not online. ultralegomaster5096
Joined: 17 Jan 2011
Total Posts: 4351
22 Jun 2012 11:12 AM
x = script.Parent.Position.X
y = script.Parent.Position.Y
z = script.Parent.Position.Z

while true do
for i = 1,50 do
script.Parent.CFrame = CFrame.new(x,y + 0.01,z)
wait(0.01)
end
for i = 50,1 do
script.Parent.CFrame = CFrame.new(x,y - 0.01,z)
wait(0.01)
end
end

There's no output. The brick moves up 0.01, once, and does not repeat. I'd like it to repeat, I can't figure out why it isn't working though.

~Death to lazy builders. Remove the CFrame tools. Command bar all the way. -pauljkl
Derpity derp derp. My favorite saying.
Report Abuse
HilariousDwarf is not online. HilariousDwarf
Joined: 20 Aug 2010
Total Posts: 2020
22 Jun 2012 11:18 AM
for i = 50,1 do

the 50 and 1 are the wrong way round here, thats all I can see wrong at the moment.
Report Abuse
gamehero is not online. gamehero
Joined: 12 Jun 2007
Total Posts: 1455
22 Jun 2012 11:19 AM
I think I fixed all the errors.. Sorry for not testing it first.


x = script.Parent.Position.X
y = script.Parent.Position.Y
z = script.Parent.Position.Z

while true do
for i = 1,50,0.01 do
script.Parent.CFrame = CFrame.new(x,y + i,z)
wait(0.01)
end
for i = 50,1,-0.01 do
script.Parent.CFrame = CFrame.new(x,y + i,z)
wait(0.01)
end
end
Report Abuse
ultralegomaster5096 is not online. ultralegomaster5096
Joined: 17 Jan 2011
Total Posts: 4351
22 Jun 2012 11:20 AM
Tried that, inverts behavior. I probably derped so hard, I'm kinda new to for loops :P

~Death to lazy builders. Remove the CFrame tools. Command bar all the way. -pauljkl
Derpity derp derp. My favorite saying.
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
22 Jun 2012 11:21 AM
Those are read only values, you need to add a vector3
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, -.01, 0)
also you can't wait that short of a time, the minimum wait time is
wait() which is about .03 seconds
also if you want to count down in a numeric for loop, you need to specify that, because the default counting interval is 1
for i = 50,1,-1 do
a last thing: put a wait() somewhere in you while true do loop, but outside of the for loops.
Report Abuse
ultralegomaster5096 is not online. ultralegomaster5096
Joined: 17 Jan 2011
Total Posts: 4351
22 Jun 2012 11:22 AM
Above post was a reply to Hilarious.
@game; Seems to never go on to the second for loop? Other then that, it works.

~Death to lazy builders. Remove the CFrame tools. Command bar all the way. -pauljkl
Derpity derp derp. My favorite saying.
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
22 Jun 2012 11:23 AM
if you do what I say, it'll work
Report Abuse
gamehero is not online. gamehero
Joined: 12 Jun 2007
Total Posts: 1455
22 Jun 2012 11:24 AM
Oops... Change the 50s in the for loops to 2 or something.
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
22 Jun 2012 11:27 AM
while true do
wait()
for i = 1,50 do
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, .01, 0)
wait()
end
for i = 50,1,-1 do
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, -.01, 0)
wait()
end
end
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
22 Jun 2012 11:28 AM
I hope you realize it is only going to move half a stud in about 1.5 seconds
Report Abuse
ultralegomaster5096 is not online. ultralegomaster5096
Joined: 17 Jan 2011
Total Posts: 4351
22 Jun 2012 11:30 AM
@kill;
Thanks! Wasn't aiming for a specific...Whatever you call it, can't speak today lol. I can always change how far it moves, just wanted to get it working first.

~Death to lazy builders. Remove the CFrame tools. Command bar all the way. -pauljkl
Derpity derp derp. My favorite saying.
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