Hello there! So my question is regarding a slight camera pan i’m trying to create for a main menu screen, the camera is on scriptable and at the cframe that i want, but i want when you move my mouse either left or right or up and down, it will move slightly in that direction. I’ve searched for this, but not having much luck, the closes one i could find looked like this
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 = Vector2.new(Camera.ViewportSize.X/2, 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 = Vector3.new((Mouse.X-Center.X)/Scale, (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 * CFrame.new(DefaultCFrame.p + MoveVector) end game:GetService("RunService").RenderStepped:Connect(Update) -- update every frame
But i’s not working. Keeps moving my camera elsewhere despite changing the “DefaultCFrame” to what i want. I’ve also experimented with changing the camera focus on mouse move, or renderstepped, or heartbeat, and then using the mouses orign or hit, or target.CFrame, but nothing. Can anyone help?