How to make Camera Follow Mouse?

I have seen many videos on this topic but every single one has the camera following mouse any where.

Want: just the first 10 sec.

I want the camera to follow the mosue like this. In video the camera will stop moving/ has limits. How do I go about doing this?


There are a couple of examples around the Dev Forum and on YouTube.

I’ve slightly rennovated the script.

In a nutshell, MAX_TILT determines the maximal angle a camera may tilt in a direction, and this part calculates tilt percentage according to the mouse’s distance from the edge of the screen (100%): (mousePos.Y - camera.ViewportSize.Y/2) / camera.ViewportSize.Y).

MAX_TILT could also be different for X and Y.

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local MAX_TILT = 10

local camera = workspace.CurrentCamera
local cameraPart = workspace.CameraPart

	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

RunService:BindToRenderStep("MenuCamera", Enum.RenderPriority.Camera.Value +1, function(deltaTime)
	local mousePos = UIS:GetMouseLocation()
	camera.CFrame = cameraPart.CFrame * CFrame.Angles(
		math.rad(((mousePos.Y - camera.ViewportSize.Y/2) / camera.ViewportSize.Y) * -MAX_TILT),
		math.rad(((mousePos.X - camera.ViewportSize.X/2) / camera.ViewportSize.X) * -MAX_TILT),

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.