Camera manipulation issue

I’m trying to make my camera face my character’s humanoid root part from 20 studs away, but the script doesn’t work.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local event = game.ReplicatedStorage:WaitForChild("Event")
local ts = game:GetService("TweenService")

camera.CameraType = Enum.CameraType.Fixed

uis.InputBegan:Connect(function(input, gps)
	if input.KeyCode == Enum.KeyCode.E and not gps then
		print("uwu")
        camera.CameraType = Enum.CameraType.Fixed
		camera.CFrame = char.HumanoidRootPart.CFrame + char.HumanoidRootPart.CFrame.lookVector * 20
		camera.CFrame = CFrame.new(camera.CFrame.Position, char.HumanoidRootPart.Position)
	
		
	end
end)

The issue is, the camera will look somewhere else sometimes.

Try using CFrame.lookAt().
Hope this helps :slight_smile:

Forces you to look at your player 20 studs away
image

https://gyazo.com/7fa9d4937bbd158587168eddc02b503b

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")

local CurrentCamera = workspace.CurrentCamera
local RS = game:GetService("RunService")

local function update()
	local PositionFrame = (HRP.CFrame + (HRP.CFrame.LookVector * -20)) + Vector3.new(0,10,0)
	CurrentCamera.CFrame = CFrame.lookAt(PositionFrame.Position, HRP.Position)
end

CurrentCamera.CameraType = Enum.CameraType.Scriptable
RS:BindToRenderStep("SetCameraBehind",Enum.RenderPriority.Character.Value,update)
1 Like