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: Not?

Previous Thread :: Next Thread 
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
23 Jan 2012 05:38 PM
What would be an alternative to "if workspace:FindFirstChild("Part") == nil"? Would it be if not workspace:FindFirstChild("Part")?

† KMXD †
Report Abuse
MXrcr20 is not online. MXrcr20
Joined: 01 Oct 2008
Total Posts: 2644
23 Jan 2012 05:40 PM
Just take off the "== nil" at the end of it.

== nil just looks to see if it's not there.
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jan 2012 05:42 PM
If not would work, I'm assuming.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
23 Jan 2012 05:44 PM
@MX I need it though. :/

@UFail I will try it then.

† KMXD †
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jan 2012 05:47 PM
Ozzy wrote a thing about truthy values. I don't have the link, but it goes like this.

if string~="abc" then -- a truthy value
so you would also be able to do
if not string=="abc" then

you can also do this

if bool then --same as "if bool==true then", b/c its a truthy value
or
if not bool then --same as "if bool==false then" ''
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jan 2012 05:49 PM
@epic

http://wiki.roblox.com/index.php/Operators#Logical

Right page, correct?
Report Abuse
Cyrok is not online. Cyrok
Joined: 11 Jan 2012
Total Posts: 630
23 Jan 2012 05:53 PM
Knightmare had it right the first time, guys.

"if not workspace:FindFirstChild("Part") then"

Is the same as saying:

if game.Workspace:FindFirstChild("Part") == nil

{ I have an OCD when it comes to non-camelCase variables/custom functions. }
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
23 Jan 2012 05:55 PM
OK, thanks guys.

† KMXD †
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jan 2012 06:06 PM
@UFAIL2; Yes, that is it.

@Cyrok; I know, I was just trying to further explain. Btw, are you an alt of someone? You know way too much about scripting to have joined this year.
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jan 2012 06:08 PM
@epic

You can learn Lua before playing Roblox.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
23 Jan 2012 06:08 PM
Not entirely.
if not workspace:FindFirstChild("Part") then
is the same as saying:
if workspace:FindFirstChild("Part") == nil or workpsace:FindFirstChild("Part") == false then

but it's much faster for the computer :D
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jan 2012 06:19 PM
@UFAIL2;

I realize, that but how many kids even knew about the word "Lua" before Roblox?
Report Abuse
Cyrok is not online. Cyrok
Joined: 11 Jan 2012
Total Posts: 630
23 Jan 2012 06:50 PM
@epicfail22

Portuguese kids did.

{ I have an OCD when it comes to non-camelCase variables/custom functions. }
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jan 2012 07:03 PM
^
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jan 2012 08:27 PM
Ahahaha. Wait, is it an actual word in portuguese? I knew it's origin was portuguese.
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jan 2012 08:30 PM
'Lua' means moon in Portuguese.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
26 Jan 2012 07:04 PM
:D I learned something new!
Report Abuse
TheNewScripter is not online. TheNewScripter
Joined: 02 Mar 2010
Total Posts: 2432
26 Jan 2012 07:35 PM
@MX

Actually, saying `~= nil` is checking if it isn't nil. Saying:

    if Workspace:FindFirstChild("Part") then

That would run as long as it doesn't return false, nil, and I think 0... Not sure about the 0 though. Otherwise, it is recommended that you use comparisons, but not required.

「TheNewScripter」
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
26 Jan 2012 07:38 PM
In a condition, nil and false always return false. Everything else returns true. That's why you never need to use the boolean operators "==" and "~=" with few exceptions such as comparing objects.

print(1 and "a" or "b")-->a
print(nil and "a" or "b")-->b
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