I'm making a cover system and I want to make it so that if the camera is facing behind the humanoid root part then when the player aims, it will stop the crouching animation and have the camera stand up to look over the cover. I searched my question up and found a post. I tried the code but I seemed to only update when I move the character (and not when I turn the camera).
RunService.Heartbeat:Connect(function()
local angle = math.acos(
math.clamp(
camera.CFrame.LookVector:Dot(HRP.CFrame.LookVector),
-1,1)
)
local backwards = false
if angle > math.pi/2 then
backwards = true
end
end)
And sometimes it gets backwards and forwards mixed up depending on which direction the character is facing relative to world space. Any help is appreciated.
