technically its working, but it’s janky and it is following every movement of the head, i don’t want that, only to up and down movement (sorry i forgot to specify)
CameraSubject can work but it give other problems because we change it into a part instead of the humanoid and because i want to do other things based on the position
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer
local character = player.Character
runService.RenderStepped:Connect(function()
local head = character.Head
local x,y,z = head.CFrame:ToOrientation()
camera.CFrame *= CFrame.Angles(0,0,z)
end)
im using the script that you provided but there is a problem, when i play the animation and the camera is too close from the character, the camera start spinning in a direction and the position get changed from the position before playing the animation
To make sure I understand, I actually have something similar to what you are looking for I believe, are you simply trying to make it so if you rotate your camera, the head part will follow instead of turning the entire player instance?
You can use your character’s neck (Motor6D), because it gets animated when animation plays.
local OldCamCF
local runService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local neck = player.Character.Torso.Neck
runService.RenderStepped:Connect(function()
local NewCamCF = neck.Transform
if OldCamCF then
local _, _, Z = NewCamCF:ToOrientation()
local X, Y, _ = NewCamCF:ToObjectSpace(OldCamCF):ToEulerAnglesXYZ()
game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(X, Y, -Z)
end
OldCamCF = NewCamCF
end)
From what i see you want to limit camera movement in one axis, soo you can rewrite your camera CFrame by their 2 components and replace third one with your angle, remember it may not work well with 3rd person soo try to use this behavior only when player is in first person