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: Does "not" affect everything in if statement?

Previous Thread :: Next Thread 
1cooldude361 is not online. 1cooldude361
Joined: 13 Mar 2010
Total Posts: 4403
10 Apr 2013 07:10 AM
For example:

if not player.Name == "1cooldude361" and player.Name == "untamedangel44" then

Would having the not after the if make it so the player's name can't be 1cooldude361 OR untamedangel44, or will it only make it so the player's name can't be 1cooldude361? To make it so it can't be either one, would it be:

if not player.Name == "1cooldude361" and not player.Name == "untamedangel44" then

?

MUST. RUIN. CHILDHOOD.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
10 Apr 2013 07:13 AM
Well, to answer your question, no. It only affects the data immediately following it.

However, I think you should be able to answer these sort of questions yourself, in the future. You can experiment with stuff like:

print(not "cooldude")
print(not "cooldude == "cooldude")

and so on...
Report Abuse
1cooldude361 is not online. 1cooldude361
Joined: 13 Mar 2010
Total Posts: 4403
10 Apr 2013 07:16 AM
Yeah, I know. There was this line in my script, and so I was confused as to how it wasn't working. Sadly, I already had the not's after every and, so this didn't help me with my script at all. Luckily, it's new info that I can be sure on. So, thanks.

MUST. RUIN. CHILDHOOD.
Report Abuse
1cooldude361 is not online. 1cooldude361
Joined: 13 Mar 2010
Total Posts: 4403
10 Apr 2013 07:23 AM
Could you guys fix this little part of my script, too?

b = game.Workspace:GetChildren()
for i = 1, #b do
if b[i].ClassName == "Model" and b[i].Name ~= "FFAMap" and not b[i]:findFirstChild("Humanoid") then --This if statement is the error line. Nothing appears in the output, but it stops putting messages up when it gets to this line (I removed the insertion of the messages so the script was smaller for you guys). Any idea what's wrong with it?

MUST. RUIN. CHILDHOOD.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
10 Apr 2013 07:34 AM
Before the if line, print the classname, name and that third condition in the if statement, so you can know what is going on.
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
10 Apr 2013 07:41 AM
It's more efficient and easier to read to use a generic for:

for _, v in ipairs(Workspace:GetChildren()) do
if v:IsA("Model") and v.Name ~= "FFAMap" and not v:FindFirstChild("Humanoid") then
--stuff and things
end
end
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
10 Apr 2013 07:59 AM
More efficient is not really valid. 0.05 seconds different per 5000 isn't a lot.
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
10 Apr 2013 12:35 PM
True, the readability is there, and there's less to type, so less to mess p.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
10 Apr 2013 12:40 PM
Good points. I prefer the second method too.
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