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: Help with 'while' loops?

Previous Thread :: Next Thread 
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
16 May 2017 02:58 AM
example:

---------

active = false

while active == true do
--code
end

active = true

---------

the while code will not activate, since the "active" variable is being set to true AFTER the loop, is there any way to go around this? i.e. make the 'while' loop activate whenever and whereever the variable is set to true?
Report Abuse
CyansAstronomy is not online. CyansAstronomy
Joined: 25 Feb 2016
Total Posts: 2534
16 May 2017 03:13 AM
It instantly sets active from false to true so it would work?


R$30,911 | aka CyanSparkleTime \ Evercyan \ Sparklexity
Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
16 May 2017 07:23 AM
not the case for me, i'm doing ## ## with idle/attack mode and i have a while loop along the lines of "while idle == true" and "while attack == true" and in the end of the attack loop (when player dies, leaves game etc) it sets attack to false and idle to true, and because the attack loop is further in the script (in terms of lines) than the idle loop, setting the idle variable to true does not trigger the idle loop, i'll elaborate more if i need to
Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
16 May 2017 07:25 AM
hashtags at the begnning is "an artificial intelligence"
Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
16 May 2017 07:38 AM
for example this will not print anything

active = false

while active == true do
wait(.1)
print('test')
end

active = true
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
16 May 2017 09:20 AM
local active = false

function loop()
print("activated")

while (active) do
print("running")
wait(1)
end

print("deactivated")
end



function turnOn()
if (not active) then
active = true
spawn(loop)
end
end

function turnOff()
active = false
end
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