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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|