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 » Scripters
Home Search
 

Re: for i = 1, 10 do loop is broken

Previous Thread :: Next Thread 
Cyerwyn is not online. Cyerwyn
Joined: 09 Mar 2013
Total Posts: 3442
14 Nov 2015 10:17 AM
It won't work, but it worked 10 minutes ago

weak = game.Workspace.weak

for i = 1, 1000 do
weak.BrickColor = BrickColor.Random()

end


It changes once and doesnt change again. Any ideas?



They say after your death, your brain is still active for 7 minutes. In those 7 minutes, you relive your entire life. What if you're in those 7 minutes?
Report Abuse
mario118118 is not online. mario118118
Joined: 05 Jul 2012
Total Posts: 245
14 Nov 2015 10:19 AM
You need a wait() in there, or it will break.
Report Abuse
BloxBuilder900 is not online. BloxBuilder900
Joined: 31 Mar 2009
Total Posts: 2231
14 Nov 2015 10:21 AM
What error are you getting?
Also, your title differs from the code - you have 1, 10 in the title and 1, 1000 in the loop
Report Abuse
isaacsoccer is not online. isaacsoccer
Joined: 22 Jul 2010
Total Posts: 430
14 Nov 2015 10:21 AM
After the "for i=1, 1000 do" on the next line place a wait like this:

for i=1, 1000 do
wait(1)
weak.BrickColor = BrickColor.Random()

end
Report Abuse
mario118118 is not online. mario118118
Joined: 05 Jul 2012
Total Posts: 245
14 Nov 2015 10:21 AM
So if you have 1,1000 and you need that to happed in 100 seconds then put wait(0.1). But if you want it to take 10 seconds use wait(0.01)
Report Abuse
Cyerwyn is not online. Cyerwyn
Joined: 09 Mar 2013
Total Posts: 3442
14 Nov 2015 10:21 AM
Thank you guys



They say after your death, your brain is still active for 7 minutes. In those 7 minutes, you relive your entire life. What if you're in those 7 minutes?
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
14 Nov 2015 10:22 AM
without a wait() it will just go to the very last one. Because w/o a wait() it does everything in no time at all.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
14 Nov 2015 10:24 AM
and if it does something that eats cpu, without a wait(), you'll game obvsly will crash


-wiki before u forum
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Nov 2015 11:27 AM
OP the real answer is that it actually changes 1000 times, you just didn't see it because it happened too quickly.
Report Abuse
Locard is not online. Locard
Joined: 13 Apr 2014
Total Posts: 3516
14 Nov 2015 11:33 AM
@mario The fastest wait() goes down to only 1/30 of a second, not 1/100 of a second.
Report Abuse
mario118118 is not online. mario118118
Joined: 05 Jul 2012
Total Posts: 245
24 Nov 2015 03:28 PM
Meh Never Mind
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
24 Nov 2015 08:41 PM
@Locard
The fastest time to wait is roughly 1/60 of a second

while game:GetService("RunService").RenderStepped:wait() do

end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Nov 2015 09:43 PM
That's not a "wait", that's just a yield until an event is invoked.
The smallest "yield" would just be to not yield, or to do something useless which takes a minuscule amount of time to execute. In terms of _actually_ yielding, coroutine.yield()
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
24 Nov 2015 09:50 PM
ew and he tried to do that in the condition, why do people still do that
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Nov 2015 09:53 PM
Yeah I never got why people did that, like "while wait() do" or whatever. I think just gross.
Report Abuse
heavylifterman192 is not online. heavylifterman192
Joined: 18 Oct 2015
Total Posts: 201
24 Nov 2015 10:05 PM
It makes it faster so it evaluates wait() instead of wait() And true.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Nov 2015 10:08 PM
Uh no, "while wait() do" is actually less efficient because "while true do" is going to be optimized, there is no evaluation of "true".
Report Abuse
heavylifterman192 is not online. heavylifterman192
Joined: 18 Oct 2015
Total Posts: 201
24 Nov 2015 10:11 PM
Even if that were true, less code = slightly faster. And wait is going to be evaluated either way
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Nov 2015 10:12 PM
"less code = slightly faster" not even close.
And no, the values returned from the wait has to be evaluated. If you are going to keep on arguing with me when you don't even know how it compiles then you must be pretty dumb. The least you could do is think.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
25 Nov 2015 10:11 AM
looks like heavylifterman92 doesn't understand the compile-time and run-time, and anyone who cares about compile-time is bad
Report Abuse
Link5659 is not online. Link5659
Joined: 04 Jun 2012
Total Posts: 4525
25 Nov 2015 10:15 AM
\o/ we got this!
Report Abuse
heavylifterman192 is not online. heavylifterman192
Joined: 18 Oct 2015
Total Posts: 201
25 Nov 2015 10:30 AM
Lol except Lua doesn't compile.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Nov 2015 01:18 PM
Except that you're stupid because it compiles into an intermediate form because interpreting bytecode is far easier, faster, and smaller than interpreting source coded directly.
Report Abuse
jody7777 is not online. jody7777
Joined: 22 Feb 2009
Total Posts: 1343
25 Nov 2015 01:38 PM
lua is compiled down to byte-code like java, then that is interpeted by the lua virtual machine

less code = -0.00000001 seconds

FOR THE CAUSE
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Nov 2015 01:41 PM
'less code = -0.00000001 seconds'
no.

At compile-time, maybe. In which case if you're using such a stupid way to measure it because it's only done once, then don't use local variables, don't make variables with names larger than 1 character, don't use tabs, etc.

Oh wait, you guys are stupid for thinking more code = slower.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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