Player to Player Proximity Detection

Hello!

I’m working on a fleshed out combat system for an upcoming release, wherein the combat system itself will not boot up until a player is near another player, and they both have their weapons equipped.

The latter half of that is extremely easy to do, but I’ve had some trouble detecting when a player is near another player and especially so since I will need their Player instance to boot up the system.

Does anyone know of any methods to detect when players are near each other that supply the player instances? Any help is appreciated.

There are several ways of doing this. A good way would be to use the player.DistanceFromCharacter(distance) function.

Try this!

2 Likes

You can use magnitude to calculate the distance from a player.

Or you can use this

These two will help you with your code.

2 Likes

This solution looks extremely promising, going to do some quick testing and I’ll mark it as the solution if everything checks out. Thanks!

Yep, exactly what I was going for, thank you!

2 Likes