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: Can I assign true/false to a variable?

Previous Thread :: Next Thread 
awsomeness7878 is not online. awsomeness7878
Joined: 23 Nov 2008
Total Posts: 9512
22 Jan 2013 01:42 PM
Can I say something like:

X = true

while true do

if X == true then

X = false

elseif X == false then

X = true

end

end
Report Abuse
spookyBen is not online. spookyBen
Joined: 13 Dec 2009
Total Posts: 6581
22 Jan 2013 01:44 PM
This is something I've been wondering for a while. I'm not sure.
Report Abuse
triston220 is not online. triston220
Joined: 08 Mar 2010
Total Posts: 1861
22 Jan 2013 01:45 PM
X = true

while true do
X = not X
wait(1)
print(x)
end
Report Abuse
awsomeness7878 is not online. awsomeness7878
Joined: 23 Nov 2008
Total Posts: 9512
22 Jan 2013 01:47 PM
So you can?

And I can see the "X = not X" being convenient.
Report Abuse
Th30racle is not online. Th30racle
Joined: 03 Nov 2012
Total Posts: 214
22 Jan 2013 01:52 PM
Yes, you can.
Report Abuse
triston220 is not online. triston220
Joined: 08 Mar 2010
Total Posts: 1861
22 Jan 2013 02:32 PM
Yeah, using not can save you quite a bit of time.
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
22 Jan 2013 02:45 PM
@op

X = true

while true do

if X then

-- The same as " if X == true then ", more efficient to do " if X then ", also, it can work as if it is there or i.e., ( if game.Workspace.Brick ~= nil then ) can work as ( if game.Workspace.Brick )

X = false

elseif not X then -- Same as " if X == false then "

X = true

end

wait() -- Always add a wait when doing "while true do" because it can and most likely will crash your game if you don't.

end


~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
22 Jan 2013 02:46 PM
Additionally, since it may not have sunk in, you can do this:

local b = 5
local a = b == 5


Any intermediate in any operation can be set to a variable.

(The exception being where something returns multiple values, you can't set one variable to multiple values explicitly, [but you could wrap them up in a table or something])
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