Making the camera face the player's mouse

When the player holds down right click, I want the camera to face their mouse.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local MouseFace = false

mouse.Button2Down:Connect(function()
	MouseFace = true
	while MouseFace == true do
        camera.CFrame = () -- Face camera at player's mouse here
        wait()
	end
end)

I’m not the best when it comes to CFrames lol

U mean something like that?

https://devforum.roblox.com/t/how-do-i-make-camera-follow-player-mouse/973208/6?u=gabko14

Do you want the body to move with mouse or camera

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local MouseFace = false

mouse.Button2Down:Connect(function()
	MouseFace = true
	while MouseFace == true do
        camera.CFrame = CFrame.lookAt(camera.CFrame.Position, mouse.Hit and mouse.Hit.Position)
        wait()
	end
end)
1 Like

camera should also be defined

local camera = workspace.CurrentCamera

assuming it was a segment of his actual script

I’ve done that and it works, however it’s really sensitive and fast. Is there a way to make it slower?

tween the camera’s CFrame to the target, that should smooth it out

Could you show me how to tween it?

Here’s an example:

TweenService:Create(camera, TweenInfo.new(2), {CFrame = CFrame.lookAt(camera.CFrame, mouse.Hit and mouse.Hit.Position)}):Play()

Thanks it works like a charm! I had to change camera.CFrame to camera.CFrame.Position but it’s working!