How would I make a script that when moving your mouse in the menu screen, it moves your camera slightly

I’m a little of a mediocre scripter.
Example of what I’m talking about:
Notice as your camera moves as you move your mouse across the screen.

I’m just in a learning phase where I am in no way shape or form ready to script a full fledged game, so I’m sticking to progressing my scripting knowledge. Thanks!


Camera mode like Fixed and Custom?

I think that you’d be able to do it by locking the players mouse to the center of their screen.

Have you played the example game?
The mouse is completely free inside of the game, but the camera slightly moves and reacts to the mouse.

Base the camera on a part, and station the part in the opposite the direction of the mouse (if the mouse is 5 studs away from the part on the X axis, the part will move -5 on the same axis).

The reason why I said the opposite direction is because the camera will point toward the part/direction, not where the mouse is, making it look like the mouse has moved the screen.

You may have to learn how to get the position of the mouse on the world axis through this.

1 Like

When you say base the camera on a part, do you mean camera focus on a part?

Yes, set the CameraSubject to the part.

Also, you may have to interpolate the camera onto the direction of the part.

1 Like

Would this work? It takes the mouse’s position and converts it into a start from the center of the screen and makes it have a range from -1 to 1 on each axis.

local RestCF =,0,0) -- where the camera should be when the mouse is in the center of the screen
local Camera = workspace.CurrentCamera -- getting the current camera
local UserInputService = game:GetService("UserInputSerivce") -- Getting userinputservice
UserInputService.InputChanged:Connect(function(inputObject, GPE)
	local Vector = * 2 - 1, inputObject.Position.Y/Camera.ViewportSize.Y * 2 - 1)
	if math.abs(Vector.Magnitude) >= Deadzone then -- Define a deadzone, can be 0 if you want no deadzone.
		 Camera.CFrame = RestCF * * 5, Vector.Y * 5, 0) -- X moves it side to side, Y moves it up and down, and Z moves it forward and backward
		-- I am multiplying the vector by 5 to make it move more than just 1 stud, as 1 stud isn't that much movement.
		Camera.CFrame = RestCF

You might find this useful toward the final product you are looking for.

It explains the reasoning for the code, and organizes it as a possible solution to your needs.

local Mouse = game.Players.LocalPlayer:GetMouse()
local Camera = game.Workspace.CurrentCamera

local DefaultCFrame = Camera.CFrame
local Scale = 200

function Update()
    -- get the center of the screen
    local Center =, Camera.ViewportSize.Y/2)
    -- get the movement (it's in studs, and the mouse properties are in pixels, so you want to divide it by your scale to not move the camera really really far)
    local MoveVector =, (Mouse.Y-Center.Y)/Scale, 0)
    -- CFrame * CFrame makes it work the same regardless of rotation, where addition just makes it work for one direction
    Camera.CFrame = DefaultCFrame * + MoveVector)

game:GetService("RunService").RenderStepped:Connect(Update) -- update every frame

(Its the solution for colbert2677’s post.)


If this worked, you could mark this as a solution so I know you don’t need more help. If you have questions, please ask! :wink:


I do. With your script, it more or less moves the actual camera instead of pointing it.
I’m also commenting out some lines and searching up some things in order to understand better.

I did:

while true do
	repeat wait() until Active
	while Active do
		game.Workspace.CurrentCamera.CFrame = game.Workspace. *name of the part you want your camera attached to* .CFrame*CFrame.Angles(math.rad((((mouse.Y-mouse.ViewSizeY/2)/mouse.ViewSizeY))*-100),math.rad((((mouse.X-mouse.ViewSizeX/2)/mouse.ViewSizeX))*-100),math.rad(0))
		game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable		

active is true when you want this to be active :slight_smile:


thank you for helping!! it worked i can finally continue yayyy

1 Like