How to make the player face the camera orientation?

Hi, I’m sure most of you have played bloxburg, or pls donate before, and in those games, there is a special effect they use relating to the camera. The player looks in the direction the camera is facing. If the camera is facing right, the character looks right. Don’t get this confused with shift lock, because it’s not. The feet are stagnant, just the torso moves. How can I do this?

1 Like

Try making the HumanoidRootPart’s orientation the Camera’s LookVector, edit: sorry I thought it was for the whole body, try changing the torso’s orientation for taht

1 Like

Believe this could help you out

3 Likes

I have one for the head, you can edit it to the torsos needs
ServerScriptService Server Script

local UpdateRate = 1/20

local HeadRotationRemote = Instance.new("RemoteEvent")
HeadRotationRemote.Name = "HeadRotationRemote"

local Rotations = setmetatable({}, {__mode = "k"})
HeadRotationRemote.OnServerEvent:Connect(function (Plr, Rotation)
	Rotations[Plr] = Rotation
end)

HeadRotationRemote.Parent = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")

function HandleCharacter(Character)
	local OldHead = Character:WaitForChild("Head")
	local NewHead = OldHead:Clone()
	NewHead:ClearAllChildren()
	NewHead.Massless = true
	NewHead.Transparency = 1
	NewHead.Name = "NewHead"
	NewHead.Parent = OldHead.Parent
	
	local OldWeld = Character:FindFirstChild("Neck", true)
	while not OldWeld do OldWeld = Character:FindFirstChild("Neck", true) end
	local NewWeld = OldWeld:Clone()
	NewWeld.Part1 = NewHead
	NewWeld.Name = "NewNeck"
	NewWeld.Parent = OldWeld.Parent
end

function PlayerAdded(Plr)
	HandleCharacter(Plr.Character or Plr.CharacterAdded:Wait())
	Plr.CharacterAdded:Connect(HandleCharacter)
end

Players.PlayerAdded:Connect(PlayerAdded)
for _, Plr in ipairs(Players:GetPlayers()) do
	PlayerAdded(Plr)
end

while wait(UpdateRate) do
	if next(Rotations) then
		local Rots
		for _, Plr in ipairs(Players:GetPlayers()) do
			if Rotations[Plr] then
				local Rots = {}
				for b, c in pairs(Rotations) do
					if b ~= Plr then
						Rots[#Rots + 1] = {b, c}
					end
				end
				
				if next(Rots) then
					HeadRotationRemote:FireClient(Plr, Rots)
				end
			else
				if not Rots then
					Rots = {}
					for b, c in pairs(Rotations) do
						Rots[#Rots + 1] = {b, c}
					end
				end
				
				HeadRotationRemote:FireClient(Plr, Rots)
			end
		end
		
		Rotations = setmetatable({}, {__mode = "k"})
	end
end```

**StarterPlayerScripts Local Script**

local UpdateRate = 1/20

local Players, TweenService = game:GetService(“Players”), game:GetService(“TweenService”)
local Plr = Players.LocalPlayer

local Root, Neck, R6
function HandleCharacter(Char)
Root, Neck = Char:WaitForChild(“HumanoidRootPart”), Char:FindFirstChild(“Neck”, true)

while not Neck do
	wait()
	Neck = Char:FindFirstChild("Neck", true)
end

while not Char:FindFirstChildOfClass("Humanoid") do
	wait()
end

R6 = Char:FindFirstChildOfClass("Humanoid").RigType == Enum.HumanoidRigType.R6

end
HandleCharacter(Plr.Character or Plr.CharacterAdded:Wait())
Plr.CharacterAdded:Connect(HandleCharacter)

local HeadRotationRemote = game:GetService(“ReplicatedStorage”):WaitForChild(“HeadRotationRemote”)
HeadRotationRemote.OnClientEvent:Connect(function(Rotations)
for _, Rot in ipairs(Rotations) do
local Neck = Rot[1].Character and Rot[1].Character:FindFirstChild(“Neck”, true)
if Neck then
TweenService:Create(Neck, TweenInfo.new(UpdateRate, Enum.EasingStyle.Linear), {C0 = Rot[2]}):Play()
end
end
end)

game:GetService(“RunService”).Stepped:Connect(function()
if Root and Neck and workspace.CurrentCamera.CameraSubject and workspace.CurrentCamera.CameraSubject:IsA(“Humanoid”) and workspace.CurrentCamera.CameraSubject.Parent == Plr.Character then
local CameraDirection = Root.CFrame:toObjectSpace(workspace.CurrentCamera.CFrame).lookVector.unit
if R6 then
Neck.C0 = CFrame.new(Neck.C0.p) * CFrame.Angles(0, -math.asin(CameraDirection.x), 0) * CFrame.Angles(-math.pi/2 + math.asin(CameraDirection.y), 0, math.pi)
else
Neck.C0 = CFrame.new(Neck.C0.p) * CFrame.Angles(math.asin(CameraDirection.y), -math.asin(CameraDirection.x), 0)
end
end

for _, Plr in ipairs(Players:GetPlayers()) do
	if Plr.Character and Plr.Character:FindFirstChild("Head") then
		local Humanoid = Plr.Character:FindFirstChildOfClass("Humanoid")
		
		if Humanoid and Humanoid.Health ~= 0 then
			Plr.Character.Head.CanCollide = false
		end
	end
end

end)

local Last1
while wait(UpdateRate) do
if Neck and Last ~= Neck.C0 then
HeadRotationRemote:FireServer(Neck.C0)
Last = Neck.C0
end
end```

The problem is I want it to follow the camera orientation. I guess I could just lick up the script a little. Thanks, let me test it.

1 Like

I fixed the scritp so is readable more easily

1 Like

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