How would I make a player face a part?

So currently, it looks like this.

And my code:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humrp = char.HumanoidRootPart

local part = workspace.Part

while true do
	humrp.CFrame = CFrame.lookAt(humrp.Position, part.Position)
	task.wait()
end

What I want:
To have the player face the part without leaning, but my brain is too small for the maths.

6 Likes

You could just make the player look at the Parts x & z coordinates, The y cord would be the players root part. This would make delta Y 0, so no looking up or down.

1 Like
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local head = char:FindFirstChild("Head") or char:WaitForChild("Head")

local part = workspace.Part

while true do
	head.CFrame = CFrame.lookAt(head.Position, part.Position)
	task.wait()
end

does this work?
moving the head instead

1 Like
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humrp = char.HumanoidRootPart

local part = workspace.Part

while true do
	humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(part.Position.X, humrp.Position.Y, part.Position.Z))
	task.wait()
end
18 Likes