How Make A Player Face A Certain Way

I wanted to make a fall boarder so when you fall off it make you teleport to a part.

Problem: When the player falls they get to the part with there camera facing the way they fall like this

I am wanting the player to look like this when they fall or which ever direction they fall to look like this

-- SERVER SCRIPT INSIDE FALLBOARD
---> variables
local FallEvent = game.ReplicatedStorage.Remote.FallEvent
local MainPart = script.Parent.Main 
local PadPart = script.Parent.Pad
local debounce = false 

---> main
MainPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not debounce then
			debounce = true
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			if plr then
				FallEvent:FireClient(plr)
				task.wait(0.5)
				hit.Parent.HumanoidRootPart.CFrame = PadPart.CFrame
				task.wait(1)
				debounce = false
			end
		end
	end
end)
9 Likes

You can use CFrame.lookAt to make their HumanoidRootPart look at a specific Vector3.

6 Likes

How do I do that--------------------

Hi Cyber Designer!

I have written a function to move the camera, you can customise it to your liking.
There’s probably a better way to do it, but this works so… use this!

-- local script
local function LookNormally()
	local camera = workspace.CurrentCamera
	local localPlayer = game:GetService("Players").LocalPlayer
	local character = localPlayer.Character

	if not character then
		return
	end

	local offset = Vector3.new(0, 5, 10)
	local lookOffset = Vector3.new(0, 2, 0) 

	local characterCFrame = character.HumanoidRootPart.CFrame
	local targetPosition = characterCFrame:PointToWorldSpace(offset)
	local lookAtPosition = characterCFrame:PointToWorldSpace(lookOffset)

	camera.CFrame = CFrame.new(targetPosition, lookAtPosition)
end

LookNormally()

Make a remote event and connect this function to it and everything will be ok!

I don’t know how it works or change anything

Create a remote event in ReplicatedStorage and fire it from the server when you need to update the camera position. Connect this function to this event.

In short, this function adds an offset to the character’s position - the first time from where to look and the second time where to look.

You do it like this:

character.HumanoidRootPart.CFrame = CFrame.lookAt(character.HumanoidRootPart.Position, part.Position --[[You change this to whatever the position of where you want them to look at is. It should be a Vector3]], Vector3.new(0, 1, 0))
1 Like

That did not work--------------

What did not work? How did the cframe turn out? You can do this.

CFrame.lookAt(Character.HumanoidRootPart.Position, Part.CFrame.LookVector)

When i use that i dont teleport and i just die

1 Like
Character:MoveTo(Part.CFrame.LookVector)
1 Like

Nop did not work can you see want is wrong
FallBoarder.rbxm (6.1 KB)

Oh, I see what you want! I thought you needed to rotate the camera!
I would suggest changing the character’s position like this:

-- SERVER SCRIPT INSIDE FALLBOARD
---> variables
local FallEvent = game.ReplicatedStorage.Remote.FallEvent
local MainPart = script.Parent.Main 
local PadPart = script.Parent.Pad
local lookAtPart = script.Parent.LookPart
local debounce = false 

---> main
MainPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not debounce then
			debounce = true
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			if plr then
				FallEvent:FireClient(plr)
				task.wait(0.5)
				-- changes here:
				hit.Parent:PivotTo(CFrame.new(PadPart.Position + Vector3.new(0,10,0), lookAtPart.Position))
				
				task.wait(1)
				debounce = false
			end
		end
	end
end)

Ignore the code I wrote earlier.

By the way, the current debounce system might cause problems if two players fall or an NPC touches this part. You should use a table with players who are teleporting now.

Updated code:

-- SERVER SCRIPT INSIDE FALLBOARD
---> variables
local FallEvent = game.ReplicatedStorage.Remote.FallEvent
local MainPart = script.Parent.Main 
local PadPart = script.Parent.Pad
local lookAtPart = script.Parent.LookPart

local playersTeleported = {} -- stores the names of players who are teleporting now
---> main
MainPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr then			
			if not table.find(playersTeleported, plr.Name) then -- if player not teleporting now continue	
				table.insert(playersTeleported, plr.Name) -- adds player name to list
				
				FallEvent:FireClient(plr)
				task.wait(0.5)
				hit.Parent:PivotTo(CFrame.new(PadPart.Position + Vector3.new(0,10,0), lookAtPart.Position))
				task.wait(1)
				
				table.remove(playersTeleported, table.find(playersTeleported, plr.Name)) -- removes player name from list
			end
		end
	end
end)	
1 Like

I don’t know why nothing is working. The two scripts you made both make the player go to the right spot and face the right spot but there camera dose not.

This is because you’re only changing the CFrame of the character, the camera is a seperate object

Everything is working exactly as it should.
You need to update the workspace.CurrentCamera property to look the way that the character is looking.

How do I do that
charachter limit

Hello again!
Take a look at this project. Everything works for me.
FallBoarder.rbxl (36.9 KB)

Is this what you need? If not, please describe what’s wrong in more detail. :confused: