Find the right or left of a player

Hi devs i want to find the right and left of a player with a output like this but obviously with the correct coordinates of the right and left position. I really hope i can find the answer to this as i have been stuck on it for a while.

left = Vector3.new(7, 43, 79)
right = Vector3.new(6, 35, 90)

What do you mean? You mean the left and right arm of a player? A random area on either side?

position of the player not a instance

You’re looking for this:

no i want to find if where the right and left of a player is

I have no clue what exactly you mean but I’ll give a suggestion

Use cframes to get the side relative to the player since cframes take rotation into effect also

local right = (player.Character.Head.CFrame * CFrame.new(10,0,0)).Position

local left = (player.Character.Head.CFrame * CFrame.new(-10,0,0)).Position

Then use .Position to convert it back to a Vector3

3 Likes

That’s why I suggested what I suggested. Learn about RightVector/LookVectors.

@dandcx That wouldn’t work since it would return a value of +10 on the x axis each time, which isn’t necessarily to the right of the player.

But it uses CFrames so it takes rotation into affect too

1 Like

Yeah that’s true. I over complicated it somewhat.

Use the player’s HumanoidRootPart's position in CFrame and add its LeftVector for left and negative LeftVector for right. I am not certain about its use case, but this is the method to get the vectors to the left and to the right.

Unless you’re talking about the left and right spaces specifically depending on the player’s orientation, you’re going to check whether the position of anything is either left or right to the player through cross product. Cross product is able to tell if a vector is perpendicular to two other vectors.

Alternatively, use dot product. This will also yield whether the direction is positive or negative. However, this will only tell you forward and backward if you use a vector as base that goes forward. Use a vector that goes either from left to right or vice versa. This vector should be used as base to dot product and calculated with another vector. You can get the direction by calculating the origin(HumanoidRootPart)'s position to the target.

2 Likes