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: How do I use Nil? How do I tell if somethings not there

Previous Thread :: Next Thread 
y1p is not online. y1p
Joined: 05 May 2013
Total Posts: 350
18 Jan 2016 06:24 PM
if script.Parent.Parent.Legitimacy=nil
wait()
then script.Parent:Destroy()
end

I kind of took a guess and put nil

The purpose of the script is to see if the parents parent has a bool value called Legitimacy. If it is not there then it removes itself. Help
Report Abuse
Superwarrior360 is not online. Superwarrior360
Joined: 21 Feb 2013
Total Posts: 2703
18 Jan 2016 06:25 PM
"if script.Parent.Parent.Legitimacy=nil" there should be 2 equal signs in an if statement, and also a then
if script.Parent.Parent.Legitimacy==nil then
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
18 Jan 2016 06:27 PM
if script.Parent.Parent.Legitimacy=nil
should be

if (script.Parent.Parent:findFirstChild("Legitimacy") == nil) then
--[[Do things]]
end

findFirstChild will return either
The child with that name

Or if the child is not found, nil
Report Abuse
GliconCraft is not online. GliconCraft
Joined: 17 Dec 2015
Total Posts: 99
18 Jan 2016 06:29 PM
When you're looking to see if a value, or object is nil, that means it's not there. Although, when you're writing a conditional statement like that, you have to use special operators like "==" means "equals" or "is". You also have to have a "then" at the end of the first line in the conditional statement, so for example:

if script.Parent.Parent.Legitimacy == nil then
wait()
script.Parent:Destroy()
end


This will delete the object that contains that script, if "Legitimacy" is not inside of "script.Parent.Parent"

The wait is kind of unnecessary, and also for testing, I would recommend using another way to test, instead of destroying the part that has the script, use something like:


if script.Parent.Parent.Legitimacy == nil then
wait()
print("script.Parent.Parent.Legitimacy is nil.")
end

Report Abuse
GliconCraft is not online. GliconCraft
Joined: 17 Dec 2015
Total Posts: 99
18 Jan 2016 06:30 PM
Oops, he's right. It should use script.Parent.Parent:FindFirstChild("Legitimacy") instead of what I gave you.
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