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: The "not" operator.

Previous Thread :: Next Thread 
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
05 Feb 2013 01:36 AM
## Note ##


"if" statements fire when the condition is true. Example:

    local bool=true
    if bool then -- This will fire because bool is true


## Explanation ##


The "not" operator is used to contrast a true/false variable.

Example:

    if not false then -- This would fire because it contrasts false to true because false is the opposite of true.


That is the same as:

    if true then -- This would fire because true is true.

Understand? Ok.

"not" can also be used in other situations to shorten your code.

Example:

    script.Parent.MouseButton1Down:connect(function()
        if script.Parent.Parent.Frame.Visible then
            script.Parent.Parent.Frame.Visible=false
        else
            script.Parent.Parent.Frame.Visible=true
        end
    end)


That is a simple open/close GUI script. Nevermind the parenting and stuff, I just made that up. Using the "not" statement you can shorten that to 3 lines.

    script.Parent.MouseButton1Down:connect(function()
        script.Parent.Parent.Frame.Visible=not script.Parent.Parent.Frame.Visible
    end)


See what I did there? I simply changed the Visibility of "Frame" to the opposite of what it was using "not".


## Other examples ##



    print(not true) --> false
    print(not false) --> true
    print(not not false) --> false
    print(not not true) --> true
    print(not not not not not false) --> true



I hoped this helped for some of you. (And sorry for any grammar/english mistakes. English is my second language)

--
i liek pineapples.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
05 Feb 2013 01:49 AM
Title fix^
Report Abuse
RoboTestGear is not online. RoboTestGear
Joined: 28 Dec 2009
Total Posts: 3063
05 Feb 2013 01:50 AM
yeah... wiki.roblox.com
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
05 Feb 2013 02:16 AM
eh, just felt like writing it.

--
i liek pineapples.
Report Abuse
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
05 Feb 2013 02:42 AM
I don't liek pineapples!
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
05 Feb 2013 03:56 AM
too bad.

--
i liek pineapples.
Report Abuse
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
05 Feb 2013 03:57 AM
Well I don't!
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