Make the camera rotate slightly with your mouse

I’m trying to make the camera rotate slightly with the user mouse, but i suck at math:

i made this code but he doesnt work

local Camera = workspace.CurrentCamera
local MOUSE = game.Players.LocalPlayer:GetMouse()
local FirstCF = Camera.CFrame

local function UpdateCamera()
    local MOUSE_POS = Camera:ViewportPointToRay(MOUSE.X,MOUSE.Y)
    local RAY = Ray.new(MOUSE_POS.Origin,MOUSE_POS.Direction * 500)
    local TargetName,CoordsHit= workspace:FindPartOnRay(RAY)
    -- print(target,hit)
    Camera.CFrame =FirstCF * CFrame.new(workspace.MenuVillanPart.Position,CoordsHit)
end

game:GetService("RunService").RenderStepped:Connect(UpdateCamera)

ik that Ray Cast is not the best way but as i said i suck at math

2 Likes

This sounds similar to a topic I’ve seen before.

Is this what you are trying to do?

You can probably tweak it a little to change the distance and intensity.

1 Like

no
i’ll send a example gif

2 Likes