How to make character face other character?

Hey there! I’m Nepzerox, and I’m trying to create an admin system with a ‘to’ command. While I’m able to teleport the player to the other play, I need the teleported player to face the player, which I don’t currently know how to do. I know it involves CFrame.angles(), however I’m not very good with CFrame and need help.

My code:

	['Name'] = 'To',
	['Alias'] = nil,
	['Description'] = 'Teleports you to a player',
	['Arguments'] = {'[player]'},
	['PlayerRequired'] = true,
       -- ignore above, its just a table w/ information about the command
	['Script'] = function(args, players, config, mod)
		for i, v in pairs(players) do
			if v.Character and mod.Character then
				local char = v.Character
				
				mod.Character.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)  
			end
		end
	end
}

Video of my script in action:

1 Like

use CFrame.lookAt.

quick demonstration:

character:SetPrimaryPartCFrame(DESTINATION,POSITION_TO_LOOK_AT)

for you, it would be

mod.Character:SetPrimaryPartCFrame(CFrame.lookAt(char.HumanoidRootPart.Position,mod.Character.HumanoidRootPart)) -- 2nd argument is position to look at! (vector3)
1 Like

I would just do something like

mod.Character.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position + Vector3.new(0, 0, -5), char.HumanoidRootPart.Position)

The second argument of a CFrame can be its ‘lookAt’ position.
Also, I think it’s better to use mod.Character:SetPrimaryPartCFrame(). I’ve had really annoying problems with not using that in the past.

(I only just realised that someone replied, but I’ll add something anyway)

1 Like

While this works, it doesn’t face the correct way.

That’s because the thing Kinesis is doing is “deprecated” and CFrame.LookAt has replaced it.