How to make dummy look at player on X

How can i make the dummy look at the player R6 only on the X Axis?
This does X, Y ,Z but i only need X and i dont know how to configure it

script.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.HumanoidRootPart.CFrame.Position, t.Head.Position)

script.Parent is the dummy that looks at the player

I’m gonna assume you mean the Y axis, as that’s the one that makes them rotate normally. For that you would do

script.Parent.HumanoidRootPart.CFrame = CFrame.lookAt(script.Parent.HumanoidRootPart.Position, Vector3.new(t.Head.Position.X, script.Parent.HumanoidRootPart.Position.Y, t.Head.Position.Z))

This uses CFrame.lookAt as it is newer. However, it is quite long without variables, so here’s how you would use them:

local char = script.Parent
local rootPart = char.HumanoidRootPart

... (your other code)

local tHead = t.Head
rootPart.CFrame = CFrame.lookAt(rootPart.Position, Vector3.new(tHead.Position.X, rootPart.Position.Y, tHead.Position.Z))

What this does is it does the same thing as the original script except it always uses the dummy’s Y position to look at the player. (If you do need specifically the X axis, swap it to Vector3.new(rootPart.Position.X, tHead.Position.Y, tHead.Position.Z))

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