GreedTaka
|
  |
| Joined: 12 Dec 2014 |
| Total Posts: 1503 |
|
|
| 19 Dec 2016 07:59 AM |
if t:GetChildren() ==0 then why wont this work |
|
|
| Report Abuse |
|
|
Rerumu
|
  |
| Joined: 11 Oct 2014 |
| Total Posts: 950 |
|
|
| 19 Dec 2016 08:00 AM |
| Put a # before the t, the # operator gets the length of an array or string. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2016 08:07 AM |
You're trying to set a value to a function. Simply put, in the case of the function GetChildren, this won't work.
If you're trying to check if children exist in parent "t", I think this should suffice:
Children = t:GetChildren() if Children then
end |
|
|
| Report Abuse |
|
|
Rerumu
|
  |
| Joined: 11 Oct 2014 |
| Total Posts: 950 |
|
|
| 19 Dec 2016 08:08 AM |
What are you on? Lol that's so wrong it gave me a tumour. |
|
|
| Report Abuse |
|
|
HlCOM
|
  |
| Joined: 29 Mar 2009 |
| Total Posts: 3332 |
|
|
| 19 Dec 2016 08:08 AM |
Put a # before the t, the # operator gets the length of an array or string.[2]
if #thing:GetChildren() == 1 then print('thing has 1 child') end |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2016 08:15 AM |
| I tried it, it worked for me, so I posted it. If you think it's wrong, then you can say why, without throwing insults. |
|
|
| Report Abuse |
|
|
Rerumu
|
  |
| Joined: 11 Oct 2014 |
| Total Posts: 950 |
|
|
| 19 Dec 2016 08:18 AM |
| Because no matter the amount of children in an object, GetChildren() will return an array. And array is ALWAYS regarded as "true" in if statements. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2016 08:19 AM |
Thanks, I understand now. That's better.
|
|
|
| Report Abuse |
|
|