How would i make player face a diraction when teleported?

heres the script:

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local PlayButton = script.Parent.PlayButton 
local UpdateLogButton = script.Parent.UpdateLogButton  
local MainFrame = script.Parent
local ChangeLogFrame = script.Parent.Parent.ChangeLog
local ChangeLogButton = script.Parent.UpdateLogButton
local Players = game:GetService("Players")
mouse.Icon = 'rbxassetid://117431027'

PlayButton.MouseButton1Click:Connect(function()
	MainFrame.Visible = false
	char:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(-40.768, -4.781, -46.732) --put position in ()
	wait(0.5)
	Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end)

UpdateLogButton.MouseButton1Click:Connect(function()
	ChangeLogFrame.Visible = true
end)

how would I modify it so player faces the direction i want?
here’s a picture of what it is rn


sorry the word face cutted off

Change

char:FindFirstChild("HumanoidRootPart").CFrame =
		CFrame.new(-40.768, -4.781, -46.732) --put position in ()

to

char:FindFirstChild("HumanoidRootPart").CFrame =
	CFrame.new(-40.768, -4.781, -46.732)
	*CFrame.Angles(0,math.pi,0)
	-- times 180 angles on y axis (math.rad(180) is math.pi)

Though, I would recommend using a part facing where you want the player to teleport.

local teleportPart = [put part to part here]

When teleporting the player, use this:

character.HumanoidRootPart.CFrame = teleportPart.CFrame

Also, this is a LocalScript you’re using, you want to use a RemoteEvent to communicate and teleport the player on the server.

char:FindFirstChild(“HumanoidRootPart”).CFrame = CFrame.new(-40.768, -4.781, -46.732) * CFrame.lookAt(Vector3.new(-40.768, -4.781, -46.732), Vector3.new(-40.768, -4.781, -46.732) + Vector3.new(direction).Unit)

Using CFrame.Angles as Aeventy suggested would definitely work, but for this it seems like a part would be much easier to use and change. If you just insert a part into the workspace, you can get that part’s CFrame (which contains both rotation and position data) and use it as the HRP’s new CFrame, letting you easily change wherever you want the spawn to be!

how would i change my checkpoint script too?
heres the script:

local spawn = script.Parent
spawn.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
		if not checkpointData then
			checkpointData = Instance.new("Model", game.ServerStorage)
			checkpointData.Name = "CheckpointData"
		end
		
		local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
		if not checkpoint then
			checkpoint = Instance.new("ObjectValue", checkpointData)
			checkpoint.Name = tostring(player.userId)
			
			player.CharacterAdded:connect(function(character)
				wait()
				character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
			end)
		end
		
		checkpoint.Value = spawn
	end
end)

i want the rotation but not the position ;-;

character.HumanoidRootPart.CFrame = teleportPart.CFrame * CFrame.Angles(0, math.rad(180), 0)

Try this, it will teleport player to the part, then rotate it 180 degrees.

Or, you can rotate the teleport part into right direction, so that the cframe would face in the direction which you wanted to.