How do I make a player look at another with alignOrientation?

I don’t know how to do this.

My current code:

	local character = player.Character
	
	local align = Instance.new("AlignOrientation")
	align.Name = "ThisIsYourFault"
	align.Parent = character
	align.Enabled = true
	align.Attachment0 = character.HumanoidRootPart.RootAttachment
	align.Attachment1 = target.Parent.HumanoidRootPart.RootAttachment
	align.RigidityEnabled = true

The result:


It turns the player around, instead of facing. I’m pretty sure I know why this happens but does anyone know how to make it face the player?

AlignOrientation does not make one attachment face another - it makes one attachment COPY the orientation of the other. If I were you I would place attachment1 inside your characters humanoidrootpart in addition to attachment0. On renderstep, update attachment1’s “WorldCFrame” like so:

align.Attachment1.WorldCFrame = CFrame.new(character.HumanoidRootPart.Position, target.Parent.HumanoidRootPart.Position)
1 Like

Thank you, sorry for the late response. My notifications aren’t working correctly. Will try.

1 Like

Also, you can only use renderstepped in localscripts so I’ll use heartbeat instead.

doing this in a local script will reduce the load on the server and make the player look with less latency. I would recommend this :relaxed:

Wouldn’t other players not be able to see the rotation then?

ROBLOX gives you network ownership of your own character so that you dont experience any lag when moving etc.
Therefore any changes you make to your own character’s cframe and physics on the client are reflected on the server - this is why teleport exploits work. Other players will be able to see it.

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