Viikko
|
  |
| Joined: 23 Jan 2015 |
| Total Posts: 249 |
|
|
| 11 Jun 2016 09:25 AM |
| How do i detect if a player is like 50 studs close to a part |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2016 09:25 AM |
| Magnitude of players Torso and the Part. |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2016 09:25 AM |
| if (Torso.Position-Part.Position).Magnitude <= 50 then |
|
|
| Report Abuse |
|
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 11 Jun 2016 10:42 AM |
Why bother with magnitude? Just use DistanceFromCharacter. :/
http://wiki.roblox.com/index.php?title=API:Class/Player/DistanceFromCharacter |
|
|
| Report Abuse |
|
|
|
| 11 Jun 2016 11:26 AM |
Efficiency m8
Also you could use FindPartsInRegion()
It's honestly better to check for FindPartsInRegion() than seeing the players Magnitude to the part because you're only doing a for loop for the items in a region and than checking every single players distance...
|
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 11 Jun 2016 11:31 AM |
But by using Region3, you pay the cost of having a cuboid hitbox.
Region3 most likely checks through all parts, anyways, but through the C++ handler rather than the interpreter.
I'd still recommend checking through DistanceFromCharacter or checking the magnitude of the positions. |
|
|
| Report Abuse |
|
|
Viikko
|
  |
| Joined: 23 Jan 2015 |
| Total Posts: 249 |
|
|
| 11 Jun 2016 04:31 PM |
| thanks to all of you i'm still a little bit confused but i guess i'm going to survive |
|
|
| Report Abuse |
|
|