Walking camera system

Help me to improve this script.

So, i’ve been trying some scripts to rotate a camera left or right when a player moves.

I find it, but he need some improves.
He is not really smooth that i need, and i’m not so good on TweenService.
This are a resume of what that script do:


He move the camera to left or right when player moves.

Theres the script:

    local camera = workspace.Camera
    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(2))
    		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(-2))
    		end
    		if a == false then
    			camera.CFrame = CFrame.new(camera.CFrame.Position) * CFrame.Angles(x,y,z)
    		end
    	end
    end)

Thank you! <3

4 Likes