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
 

Can u do 2 while true do loops?

Previous Thread :: Next Thread 
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:17 PM
like this

while true do
if script.Parent.Transparency = 1 then
h = Instance.new ("Hint",Game.Workspace)
h.Text = "hi"
h.Name = "i guess a hint"
end
end
while true do
if game.Workspace['i guess a hint'] then
script.Parent.Transparency = 0
end
end


not saying i would use this script, just asking if its possible
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
08 Dec 2013 03:18 PM
will never be necessary, and will crash the best of computers

don't do it
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:18 PM
coroutine.resume(coroutine.create(function()
--script
end))
Report Abuse
FootBa11 is not online. FootBa11
Joined: 16 Sep 2008
Total Posts: 11501
08 Dec 2013 03:18 PM
Yes, but the second would never fire.

Try using coroutines.
Report Abuse
GGwashere123 is not online. GGwashere123
Joined: 10 Jun 2012
Total Posts: 440
08 Dec 2013 03:19 PM
It's two separate loops and they are ended properly, so yes. <_<
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
08 Dec 2013 03:20 PM
^ But the loop never breaks meaning the script will not continue to the next code unless you use a coroutine.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:20 PM
@GG, Nope, First loop would hog all the attention.

coroutine.resume(coroutine.create(function()
--Loop one
end))
--Loop two
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:23 PM
so..... it would be like this?

while true do
--stuff
end
coroutine.resume(coroutine.create(function()
--stuff
end))


it would do both?
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:24 PM
lol, didnt see lampwnage's post, :D
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:24 PM
Nope.
coroutine goes first.
If it doesn`t get to the coroutine there is no way for it to run.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:25 PM
I understand
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:26 PM
basically a coroutine.resume(coroutine.create(function() is a loop that lets u loop more than once?
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:27 PM
No
A coroutine just allows you to do multiple things at once
Example:

coroutine.resume(coroutine.create(function()
wait(34234)
end))
print("Hi")


------------
That will print instantly.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:30 PM
question:
how would i end that second one?
Did u forget an end?
Or is it supposed to be like that?
coroutine.resume(coroutine.create(function()
--Loop one
end))
--Loop two
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:32 PM
The end is for the function, The two parenthesis end the coroutine.create( and coroutine.resume(
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:36 PM
Say I had a function

player.Chatted:connect(function(msg)
if msg == "hi" then
player:Kick()
end)


coroutine.resume(coroutine.create(function()
if game.Workspace['Win message'] then
print ("o yes")
end
end))


Would it only lead to that if someone Chats , or would it skip to it?
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:39 PM
player.Chatted:connect(function(msg)
if msg == "hi" then
player:Kick()
end)

Since that is triggered by an event, after it is done reading it, it wont hog all the attention.

coroutine.resume(coroutine.create(function()
if game.Workspace['Win message'] then
print ("o yes")
end
end))

That coroutine isn`t really needed here.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:39 PM
Ok, heres what im trying to say:

Will the couritine not interfere with the script, like if i put it at the start, would it prevent everything from starting?
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
08 Dec 2013 03:44 PM
Coroutines pretty much pretend as if the code between them are not actually there while still executing it.



Here`s another example:
coroutine.resume(coroutine.create(function()
while wait(1) do
print("This will print")
end
end))

while wait(1) do
print("This will also print")
end

print("This will not print")


Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Dec 2013 03:46 PM
epicccc so it doeen't interfere?!?!!?!? GREAT!
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