-
What do you want to achieve?
How to rotate the player if his camera reaches a certain axis ?
-
What is the issue?
The player rotate very curtly …
-
What solutions have you tried so far?
I’ve do this :
while wait() do
if Camera.CFrame.LookVector.X > 0.8 or Camera.CFrame.LookVector.X < -0.8 then
local cameraDirection = Camera.CFrame.Rotation
local rotX,rotY,rotZ = cameraDirection:ToEulerAnglesYXZ()
local rootPartPos = HumanoidRootPart.CFrame.Position
local RootRotX,RootRotY,RootRotZ = HumanoidRootPart.CFrame:ToEulerAnglesYXZ()
HumanoidRootPart.CFrame = CFrame.new(rootPartPos)*CFrame.Angles(RootRotX,rotY,RootRotZ)
end
end
On top of that my script works quite randomly … 
Does anyone know by any chance ? 
do u want the player to turn away from the camera?
1 Like
while wait() do
if HumanoidRootPart.CFrame:VectorToObjectSpace(Camera.CFrame.LookVector).Z > 0 then
local cameraDirection = Camera.CFrame.Rotation
local rotX,rotY,rotZ = cameraDirection:ToEulerAnglesYXZ()
local rootPartPos = HumanoidRootPart.CFrame.Position
local RootRotX,RootRotY,RootRotZ = HumanoidRootPart.CFrame:ToEulerAnglesYXZ()
HumanoidRootPart.CFrame = CFrame.new(rootPartPos)*CFrame.Angles(RootRotX,rotY,RootRotZ)
end
end
this makes it so u can never see the characters face
2 Likes
It’s exactly that thank you so much ! 
But can you explain to me how to do that ? 
EDIT : just the if then
this? HumanoidRootPart.CFrame:VectorToObjectSpace(Camera.CFrame.LookVector).Z > 0
1 Like
Yes it is ! (rjhenhrneuhneirh)
But there are a problem I mentionned : 
so yours(Camera.CFrame.LookVector.X > 0.8 or Camera.CFrame.LookVector.X < -0.8) was only looking if the character rootpart was forever looking at the z axis
I took in account for the characters rotation with HumanoidRootPart.CFrame:VectorToObjectSpace
which basicly like aligns the camera vector to the character
and Z is the axis difference between the character torso lookvector and the camera lookvector
and if its more then > 0 aka if camera is not looking afront(-1) then
1 Like
so like

urs would work weirdly if the character was facing another way

1 Like
Camera.CFrame.LookVector.X > 0.8 or Camera.CFrame.LookVector.X < -0.8
your X part
1 Like
Ok but how can I do the same thing but the player rotate less curtly ? 
well I would just lerp the cframe or tween it
1 Like
Sorry but I’m new I need to use it at the line 7 ? 
while wait() do
if HumanoidRootPart.CFrame:VectorToObjectSpace(Camera.CFrame.LookVector).Z > 0 and Aim == true and Idle == true then
local cameraDirection = Camera.CFrame.Rotation
local rotX,rotY,rotZ = cameraDirection:ToEulerAnglesYXZ()
local rootPartPos = HumanoidRootPart.CFrame.Position
local RootRotX,RootRotY,RootRotZ = HumanoidRootPart.CFrame:ToEulerAnglesYXZ()
HumanoidRootPart.CFrame = CFrame.new(rootPartPos)*CFrame.Angles(RootRotX,rotY,RootRotZ)
end
end
oh ok I’l do it for you if you would like 
1 Like
No no, thank you but I want to do it by myself for improve myself
!
But how can I use the tween or lerp ? 
it would be harder for me to explain sorry. but you could learn from the code, Its how I started
local speed = 2 -- how fast it lerps
while true do
local dt = wait() -- time between waits
if HumanoidRootPart.CFrame:VectorToObjectSpace(Camera.CFrame.LookVector).Z > 0 and Aim == true and Idle == true then
local cameraDirection = Camera.CFrame.Rotation
local rotX,rotY,rotZ = cameraDirection:ToEulerAnglesYXZ()
local rootPartPos = HumanoidRootPart.CFrame.Position
local RootRotX,RootRotY,RootRotZ = HumanoidRootPart.CFrame:ToEulerAnglesYXZ()
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(CFrame.new(rootPartPos)*CFrame.Angles(RootRotX,rotY,RootRotZ),dt*speed)
end
end
1 Like
It feels a bit rigid still but its because wait() is not the fastest thing u can use for a loop
1 Like
Ok I have understand ! 
But it is not what I am searching, I’ll create a new topic for this ! 