Hello! I’m trying to make a movement system where the camera rotates based on the player’s movement (like if you press D, your camera rotates to the right, etc.) I found a script in the DevForum, but I do not know how to make it smooth. What the script does is intended, but it just snaps into place.
Script (NOT MINE):
local camera = workspace.Camera
local ts = game:GetService('TweenService')
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local runService = game:GetService("RunService")
runService.RenderStepped:connect(function()
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
local a = false
local x,y,z = camera.CFrame:ToEulerAnglesXYZ()
if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.A) then
a = true
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z) * CFrame.Angles(0,0,math.rad(0.5))
end
if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.D) then
a = true
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z) * CFrame.Angles(0,0,math.rad(-0.5))
end
if a == false then
camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z)
end
end
end)
Question: How do I smoothly tilt camera, based on the player’s movement?