HumanoidRootPart.CFrame just moves the part, not rotates

SO, quick and simple, when i set the humanoidrootpart’s cfame with cframe.lookat() it doesnt face it twoards the other part.

local hrp = script.Parent.HumanoidRootPart
hrp.CFrame = CFrame.lookAt(hrp.Position,ray.Instance.Parent.HumanoidRootPart.Position)

This sometimes moves the players humanoid, but doesnt rotate it twoards the hit player.
Please help, i might just be dumb but i cant figure out how to solve this, ive tried even using a tween, setting the CFrame with CFrame.new(), but none of it works.

EDIT: this is a local script, that checks if the raycast hits something with a humanoid and humanoid rp.


if ray.Instance.Parent:FindFirstChildOfClass("Humanoid") and ray.Instance.Parent:FindFirstChild('HumanoidRootPart') then
local hrp = script.Parent.HumanoidRootPart
script.Parent:SetPrimaryPartCFrame(CFrame.lookAt(hrp.Position,ray.Instance.Parent.HumanoidRootPart.Position))
1 Like

Doesnt seem to work

When clicking on the arm:

Expected:

What happens:

edit: when i did the expected, i just looked at the humanoidrootpart myself, so it didnt look upwards, with the other one i just let it go up before screen shotting

if there’s a height difference, this MAY WORK but it is not tested.

local hrp = script.Parent.HumanoidRootPart
script.Parent:SetPrimaryPartCFrame(CFrame.lookAt(hrp.Position,ray.Instance.Parent.HumanoidRootPart.Position) * Vector3.new(0, math.max(math.abs(hrp.Position.Y - ray.Instance.Parent.HumanoidRootPart.Position.Y), 0), 0)

EDIT: corrected version…?


local hrp = script.Parent.HumanoidRootPart
script.Parent:SetPrimaryPartCFrame(CFrame.lookAt(hrp.Position,ray.Instance.Parent.HumanoidRootPart.Position + Vector3.new(0, math.max(math.abs(hrp.Position.Y - ray.Instance.Parent.HumanoidRootPart.Position.Y), 0), 0)))

hey, sorry again, but this still does the same thing, where it just looks the same way as the mouse was before changing the cframe. The height of the camera isnt what im worried about, just making it look at the other part

when clicking this arm, it just stays there, not twoards the rp

Should i just put this as a bug report? I’m not sure why this doesnt work, ive done it on server and client

Im dumb, i just had to make it wait for 0.5 of a second after making the camera scriptable.