Hi, I’m just curious about how to make the CFrame line of my code ignore the Y value of the target,
because if the Y value is included it breaks quite a lot of stuff.
Here’s the line
Head.CFrame = CFrame.lookAt(script.Parent:FindFirstChild("Head").Position, victimhead.Position)
If someone could rewrite the line of code while ignoring the CFrame, that would be great
NOVEIGMA
(Vernumerator)
2
Multiply the positions by a modifier vector that does exactly what you want
--initalize this once. PLEASE reuse it.
local removeY: Vector3 = Vector3.new(1, 0, 1)
Head.CFrame = CFrame.lookAt(pointA.Position * removeY, pointB.Position * removeY)
It works because when you multiply a Vector3 by a Vector3, each component is multiplied individually:
(1, 2, 3) * (4, 5, 6)
(1*4, 2*5, 3*6)
(4, 10, 18)
And multiplying anything by zero will just give you zero, so multiplying Y by 0 on both vectors effectively removes it from consideration
4 Likes
I didn’t know that you could assign multiple values to a variable, I learned something new today. Thanks 
lV0rd
(Tin)
4
antother way is doing Vector3.new(thing.Poistion.X, 0, thing.Position.Z)
1 Like
system
(system)
Closed
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.