NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 16 Jul 2011 09:08 AM |
I've been looking over the wiki, and seen a lot of code like this:
part.Touched:connect(function(hit) if hit.Parent then --Do stuff end end
Is the check on hit.Parent strictly necessary? Surely in order to collide, the part must be a descendant of workspace, so therefore must have a non-nil parent.
Should I be doing this in my code as well, or should I remove these statements from the wiki? |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 16 Jul 2011 09:10 AM |
Yes, it's necessary.
Things like bullets remove themselves when their Touched event is fired, so when the other brick's Touched event is fired the "hit" argument's parents can be nil.
Lots of things don't do this check so they can be broken by being shot at. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2011 09:12 AM |
| I've made hundreds of Touched() scripts before. You don't really need a 'if hit.Parent then' statement, because, yes, the Parent would have to be non-nil for a Touched() function. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2011 09:13 AM |
@sncplay42 Well, except, it can be important for things like that. >.> |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 16 Jul 2011 09:44 AM |
"Lots of things ... can be broken by being shot at" - sounds like a feature.
Presumably it's still safe to use the "hit" argument, even though it has been removed? Or is it invalid to work with a :remove()d object? |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 16 Jul 2011 09:45 AM |
| It's still valid, its parent will just be nil and anything that was in it will also have been removed. |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 16 Jul 2011 10:13 AM |
| So its not like working with a finalized object in C++ then |
|
|
| Report Abuse |
|
|
Razer100
|
  |
| Joined: 28 Aug 2009 |
| Total Posts: 8066 |
|
|
| 16 Jul 2011 10:15 AM |
Everything on the wiki has not been implemented, stay away from it.
very misleading |
|
|
| Report Abuse |
|
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
| |
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 16 Jul 2011 10:17 AM |
| BaseParts haven't been implemented, apparently. Judging by Razer's post. |
|
|
| Report Abuse |
|
|
thegenius
|
  |
| Joined: 03 Oct 2008 |
| Total Posts: 3838 |
|
|
| 16 Jul 2011 10:19 AM |
Nothing is actually being physically represented?
My life has been changed forever... |
|
|
| Report Abuse |
|
|
TaslemGuy
|
  |
| Joined: 10 Jun 2009 |
| Total Posts: 12174 |
|
|
| 16 Jul 2011 10:24 AM |
Yes, you do.
"Bullets" often have the Parent of nil when they hit an object. |
|
|
| Report Abuse |
|
|
Razer100
|
  |
| Joined: 28 Aug 2009 |
| Total Posts: 8066 |
|
|
| 16 Jul 2011 10:25 AM |
@Blocco and Taco.
ALOT of things are on the wiki that are not implemented |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 16 Jul 2011 10:27 AM |
| @Razer: You've just created a dependent clause. Would you like to finish it off with an independent clause. |
|
|
| Report Abuse |
|
|
Razer100
|
  |
| Joined: 28 Aug 2009 |
| Total Posts: 8066 |
|
|
| 16 Jul 2011 10:31 AM |
| Look, you know yourself what's there and what's here. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2011 10:36 AM |
| PrismPart, StoppedTouching event, ParallelRampPart... Oh, you _DIDN'T_ want me to start listing things... kk |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
Razer100
|
  |
| Joined: 28 Aug 2009 |
| Total Posts: 8066 |
|
| |
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
LocalChum
|
  |
| Joined: 04 Mar 2011 |
| Total Posts: 6906 |
|
| |
|
Razer100
|
  |
| Joined: 28 Aug 2009 |
| Total Posts: 8066 |
|
|
| 16 Jul 2011 11:41 AM |
Implying I'm southern.
>Grow up >I'm glad to know your ability's on an online game give you the power to say I'm an "idiot" |
|
|
| Report Abuse |
|
|
lucas668
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 6183 |
|
|
| 16 Jul 2011 12:15 PM |
Razer is just jelly.
Oh yeah, and you don't need to check for the parent unless you got guns or something like it at the place you are scripting in. Otherwise, if you don't perform the check and the part is shot, this happens:
if part.Parent:FindFirstChild("Humanoid") then
- ERROR YOU NOOB PARENT IS NIL |
|
|
| Report Abuse |
|
|