LookVector Not Working, Says "Coordinate Frame expected, got Vector3"

I’m trying to place a cube in front of a player, and to do this, I’m trying to use the LookVector of the HumanoidRootPart of my character. The code looks like this:
Cube.CFrame = HumanoidRootPart.CFrame.LookVector *2

However, when I run this code, it won’t work, as it says “Unable to assign property CFrame. CoordinateFrame expected, got Vector3” When changing the code from Cube.CFrame to Cube.Position, it doesn’t show any error messages, but instead sets the cube at the center of the map (0,0,0).

Does anyone know how to fix this problem?

Edit: Hands down, this is my stupidest post yet. My bad.

3 Likes

You have the error message right in front of you. It literally tells you what went wrong, and what should be done instead.

LookVector is a Vector3. It is NOT a CFrame.
LookVector is always relative to its parent CFrame. It is NOT in worldspace, but rather an offset of the CFrame.
The correct way to do this should be:

Cube.CFrame = HumanoidRootPart.CFrame + HumanoidRootPart.CFrame.LookVector*2

Because LookVector is an offset, we have to add it back to the original CFrame.

3 Likes

Well, I feel stupid. Sorry about that, and thank you for your time :slight_smile:

1 Like