I am making my player turn towards the camera with lerp to make a smooth movement at the beginning but to remain firm when he is already facing the camera
I’m trying with lerp but my character rotates infinitely
my code here:
local camera = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local head = char:WaitForChild("Head")
game:GetService("RunService").RenderStepped:Connect(function()
if root then
local cameraDirection = camera.CFrame.LookVector
root.CFrame = root.CFrame:lerp(root.CFrame * CFrame.Angles(0,cameraDirection.Y,0),.75)
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if root then
root.CFrame = root.CFrame:lerp(CFrame.lookAt(root.CFrame.Position, camera.CFrame.Position) , 0.1)
end
end)