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: for i=[number],[number] do

Previous Thread :: Next Thread 
ScripterFTW is not online. ScripterFTW
Joined: 17 Aug 2012
Total Posts: 1450
29 Sep 2012 10:40 PM
I want to make it so that you pick a size. I made my example 5.

It makes the size negative: -5
then it is supposed to print it until positive 5 then back to -5 over and over:

>-5
>-4
>-3
>-2
>-1
>0
>1
>2
>3
>4
>5
>4
>3
>2
>1
>0
>-1
>-2
>-3
>-4
>-5...

and so on. But, my script doesn't work. It stops at positive six:

local size=5
local size=size+1
local start=(-size)
while wait() do
    for i=1,start*(-2) do
        start=start+1
        print(start)
        wait(0.5)
    end
    for i=1,start*(-2) do
        start=start-1
        print(start)
        wait(0.5)
    end
end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 10:44 PM
This is better ;)

size = -5
repeat
print(size)
size = size + 1
until size >=5
for i = 5,-5,-1 do
print(i)
end
Report Abuse
ScripterFTW is not online. ScripterFTW
Joined: 17 Aug 2012
Total Posts: 1450
29 Sep 2012 10:48 PM
Thanks miz, that works. But it doesn't do it over and over :[
But that's simple, I think i can fix
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 10:50 PM
Add an infinite loop and there you go.
Report Abuse
VanityComplex is not online. VanityComplex
Joined: 28 Aug 2012
Total Posts: 236
29 Sep 2012 11:26 PM
Ooh! Lemme try!

while true do
wait(0.01)
for i = -5,5,1 do
print(i)
wait(0.01)
end
end

Tell me if that works; I just pulled it out of thin air.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 11:28 PM
Not necessarily...
Report Abuse
VanityComplex is not online. VanityComplex
Joined: 28 Aug 2012
Total Posts: 236
29 Sep 2012 11:29 PM
Wait a minute. Nevermind.

while true do
wait(0.01)
for i = -5,5,1 do
print(i)
wait(0.01)
end
for i = 5,-5,-1 do
print(i)
wait(0.01)
end
end

I really should open Studio and test this before looking like a buffoon, but Studio hates me today...
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 11:31 PM
Nope.

(Hint *look at for loop*)(:
Report Abuse
ElectricBlazeAlt is not online. ElectricBlazeAlt
Joined: 17 Aug 2012
Total Posts: 3535
29 Sep 2012 11:35 PM
@miz - There's nothing wrong with his second one.
Report Abuse
omzig is not online. omzig
Joined: 18 Jun 2008
Total Posts: 578
29 Sep 2012 11:35 PM
Also that oculd lag the game if you had such a small wait time with while true do...
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 11:37 PM
Oh yeah, I looked at the for loop wrong ;/
Report Abuse
ElectricBlazeAlt is not online. ElectricBlazeAlt
Joined: 17 Aug 2012
Total Posts: 3535
29 Sep 2012 11:39 PM
Yeah, I know what you did; you mixed up the increment. :P
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