How to detect how far someone is to the right/left of the player

Currently I am using magnitude but magnitude includes the distance for example if you are 5 studs in front of the player and 2 studs to the right the magnitude would be something near 6(an estimate cause of straight line). However I would like to know that they are 2 studs to the right. The issue with checking x/z values is that if the player is facing left/right compared to front/back then the x/z would be different. I could just switch between checking the x/z but that would not work because of the corners/points that aren’t facing a perfect z angle or x angle. So to sum it up how would I detect how far to the right one player is compared to the other based on where the player is facing. (Basically see the magnitude between the players ignoring how far in front the player is) If you need more info lemme know.

You’d probably calculate a right triangulation between. You can also try some CFrame to orient the origin from your character and then getting the relative position of them. Not sure if the normal needs to be considered as well. Once you’ve done it, use the X axis. Y is height and Z is depth.

It’s actually really simple. I’m not sure if you’ve tried this, but I suggest getting the distance between the 2 players, multiplying that vector distance by identity vectors on the vector components you want to ignore, check if the distance is greater then zero (right) or less then zero (left), and then return the magnitude.

local distance = (Vect1.Position - Vect2.Position) * Vector3.new(1, 0, 0)
if distance.X < 0 then
     -- player is to the left
    return distance.Magnitude
else
     -- player is to the right
    return distance.Magnitude
end

Hmm, do you mean orientation? Because Afaik, regardless of orientation the vector distance will not change. It would only be different as expected if you’re position changes.

For this kind of problem I like to use object space. If you want to find a CFrame relative to another CFrame, you should use it. For example, if I wanted to know the relative CFrame of Player2 from Player1, I could do something like this:

local player1CFrame = player1.Character.HumanoidRootPart.CFrame
local player2CFrame = player2.Character.HumanoidRootPart.CFrame
local relativeCFrame = player1CFrame:ToObjectSpace(player2CFrame)
print(relativeCFrame.Position) -- this will be the relative position of player2 from player1

I suggest looking at this wiki article if you need more clarification.