Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a character look towards a target without looking up or down?

I am attempting to make a system that the player looks towards another player's torso, and it currently works like this, but it's not what I'm looking for.

local part0 = (script.Parent.Parent.Torso)
local part1 = (player2.Torso)
part0.CFrame = CFrame.new(part0.Position, part1.Position)

The issue is that when you jump and activate it, the character will look down at the target.

What I am looking for but unable to do is that the character won't look up or down towards the target, but will only rotate 360 degrees to look at the target.

If required I can give photos on what I mean

1 answer

✓ Accepted answer

You set second parameter of CFrame to a vector3 with x and z from part1 and y from part0:

part0.CFrame = CFrame.new(part0.Position, Vector3.new(part1.Position.X,part0.Position.Y,part1.Position.Z))

This discussion is preserved as it was. New answers, comments, and votes are closed.