I'm trying to make my monster look at the player's torso while following them (This is a custom monster no humanoid) but i want it to only use X and Z i want it to the ignore the Y coordinate is that even possible.
I tried using bodygryo it focuses on the player, But only on the part left surface it completely ignore's the front surface?
-- hmr is the monster's torso -- torso is the player's hmr.CFrame = CFrame.new(hmr.Position,torso.Position.X,torso.Position.Z)
error
Invalid number of arguments: 4
You can use CFrame's lookAt
parameter to make the monster look at the human's torso position. Because you set the y position to be 5, the monster will always be looking at the height of 5.
local customPosition = Vector3.new(torso.Position.X, 5, torso.Position.Z) hrp.CFrame = CFrame.new(hrp.CFrame, customPosition )
What the lookAt parameter is doing:
function lookAt(target, eye) local forwardVector = (eye - target).Unit local upVector = Vector3.new(0, 1, 0) -- You have to remember the right hand rule or google search to get this right local rightVector = forwardVector:Cross(upVector) local upVector2 = rightVector:Cross(forwardVector) return CFrame.fromMatrix(eye, rightVector, upVector2) end