Finding a players look vector for part rotation not working

Made this simple line of code:

NewHook.Rotation = Vector3.new(Player.Character.HumanoidRootPart.CFrame.LookVector.X,0,0)

And the part does not rotate, no errors.

1 Like

part.Rotation requires a Vector3 of Euler Angle values in degrees.
CFrame.LookVector is a Vector3 that is a directional unit vector, and LookVector.X is the X component of the vector, which is not an angle, and is between -1 and 1, so you’d get at most +/- 1 degree of rotation (which is not much).

You probably don’t want to set the Rotation on the part, you probably want to set the whole CFrame of the NewHook part to point a certain direction, but I can’t write the code for you here because it’s not clear from your existing code if you wanted just x-axis rotation, or if you wanted to point in the direction of the HRP LookVector, or the RightVector, or what exacly you’re trying to do. Some illustration of the problem is needed.

1 Like

Imagine a grapple hook, when you throw it its gonna hook onto something. So to do that I set the grapples CFrame to the part it touched and it worked fine, but it was facing only one direction no matter where you throw it from. I want it to point towards where you threw it from.

If you don’t care about how it’s rotated around the axis it’s pointing in, you can use the 2-argument CFrame constructor, like so:

Hook.CFrame = CFrame.new( Hook.Position, Hook.Position + direction )

Where direction is any Vector3 that’s pointing the the direction you want the hook to go. CFrame.new( point1, point2 ) makes a CFrame located at point1 with a LookVector aimed at point2. It was originally intended for setting Camera orientation, so it tries to make a CFrame where the RightVector is in the XZ plane.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.