How to make camera face the same way as the humanoidrootpart

Hello! I’m currently stuck on how i can make the camera face the same way as the humanoidrootpart. Basically i set the character to face a certain way and the camera should also be facing the same way (kinda like attach) but the camera is set to scriptable. I want to merge this with my current camera script, but i think after i get some help i can do that by myself. Any ideas? All help is appreciated!

Have you checked the roblox.developer.com page?
Camera | Roblox Creator Documentation
Camera | Roblox Creator Documentation

Doesn’t Attach work for you?

Attach does work, but then the camera can’t be set to the scriptable type which is what i still require

Change the cameras cameratype

local camera = workspace.CurrentCamera --if you already have a variable for camera, dont include

camera.CameraType = Enum.CameraType.Attach

I haven’t tested this so let me know if it errors

also, make sure it’s a local script, you cannot change a players camera type through the server unless you want to use events.

EDIT: I don’t know if you will need this but:
To change the characters camera back to how it originally was, do the same thing but camera.CameraType = Enum.CameraType.Custom

Thanks for your answer! But i have to use the scriptable type of camera, so the rest of my camera system will work. I’ve tried to find the code for how the attach camera works but to no avail (so i can adapt the code into my scriptable camera)

Here you go, this one works!

local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera

localPlayer.CharacterAdded:Connect(function(char)
	wait()
	local lookVec = char:WaitForChild("HumanoidRootPart").CFrame.LookVector
	Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, Camera.CFrame.Position + lookVec)
end)

Thank you for the response! This really helps me out! However, i’ve managed to get stuck (once again) on combining it with the previous camera script:

			local Start_CFrame = CFrame.new((Humanoid_Root_Part.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(X_Angle), 0)*CFrame.Angles(math.rad(Y_Angle), 0, 0)

			local Camera_CFrame = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(Camera_Position.X,Camera_Position.Y,Camera_Position.Z))
		    local Camera_Focus = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(NewCFrame,NewCFrame,-50000))
			local Camera_Focus = Start_CFrame + Start_CFrame:vectorToWorldSpace(Vector3.new(Humanoid_Root_Part.lookVector,Humanoid_Root_Part.lookVector,-50000))
			
			local lookVec = Character:WaitForChild("HumanoidRootPart").CFrame.LookVector
			local Test = CFrame.lookAt(Player_Camera.CFrame.Position, Player_Camera.CFrame.Position + lookVec)
			
			Player_Camera.CFrame = CFrame.new(Camera_CFrame.p,Camera_Focus.p)

Could you please help me out with this? If not hopefully i’ll manage to figure it by guessing for a while

You welcome! And this one looks a bit complicated, I’ll have a look.

Do you need to combine it however?

Thank you! I’ve never really messed with camera scripts before!

No problem, but I dont see to why you would like to combne them, could you elaborate to why? Thanks!

Sorry! I should have explained it earlier!

I’m trying to merge them so the camera faces the same way as the humanoidrootpart so you can duel properly