NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 30 Nov 2012 03:50 PM |
How would I detect when one players bumps into and touches another player?
Would I just run a .Touched event on their character, or in their torso? Is there anything special I would need to do? |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2012 03:51 PM |
| just a .Touched event in the torso, or create a Region3 around the character. |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2012 03:52 PM |
| or check .magnitude, but that would be really nasty and inefficient. |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 30 Nov 2012 03:57 PM |
| Would it run in the character? Can you touch the character, or must it be a specific part (such as the torso)? |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2012 04:00 PM |
Dude, it's just a .Touched event. You can connect it to every part in the character
for i, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do if v.className =="Part" then v.Touched:connect(function(h)
-- stuff
end) end end
put this in a localscript in starterGui |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 30 Nov 2012 04:03 PM |
I know, I'll probably end up doing that. My question was could I do:
game.Players.NeonBlox.Character.Touched:connect(function(p) --code end)
or must I iterate through every part? |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2012 04:04 PM |
| no you can't do that. You have to iterate through character:GetChildren() |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
| |
|
|
| 30 Nov 2012 04:13 PM |
| Well not all of the children of character are things that can be touched, so that is why you have to be more selective and iterate through the children, to verify that the thing you are detecting if it is touched, can actually be touched. |
|
|
| Report Abuse |
|
|