generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do i know if a player is near to a part?

Previous Thread :: Next Thread 
Viikko is not online. 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
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
11 Jun 2016 09:25 AM
Magnitude of players Torso and the Part.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
11 Jun 2016 09:25 AM
if (Torso.Position-Part.Position).Magnitude <= 50 then
Report Abuse
Aethex is not online. 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
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image