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: How do I loop?

Previous Thread :: Next Thread 
DomithicusOblivicus is not online. DomithicusOblivicus
Joined: 25 Oct 2013
Total Posts: 40
07 Jan 2014 12:29 AM
^ How do I loop in a script?
Report Abuse
ninjasamuraiux is not online. ninjasamuraiux
Joined: 23 Aug 2011
Total Posts: 5405
07 Jan 2014 12:30 AM
while true do
--stuff
wait() --number
end
Report Abuse
jakej78b is not online. jakej78b
Joined: 09 Mar 2011
Total Posts: 813
07 Jan 2014 01:11 AM
http://wiki.roblox.com/index.php/Generic_for
Report Abuse
ScriptingBoa is not online. ScriptingBoa
Joined: 28 Jan 2010
Total Posts: 35
07 Jan 2014 01:18 AM
condition
wait
end

while true do
print("Hello!")
wait(1)
end

If you do not have the wait(1) in the script then your game will crash in that instance because the script will run math.huge times in under a second.

You could also do:

for i=1, #100 do
print("Hello!")
wait(1)
end

This will print "Hello!" every second for 100 seconds. This is because #100 is in the first line. If you used "for i=1, #50 do" for the first line, it would do it for 50 seconds. If you did wait(0.5) times it would do it 100 times in 50 seconds.

You can also use anonymous functions in loops, for instance;

game.Players.PlayerAdded:connect(function(player)
if player.Name = "ScriptingBoa" then
print("Script has joined the game! Hooray!")
end
end)

"end)" is used because "(function" started a parathesis, and the "end)" closes that.

Have a nice day. :)
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