Main Menu Camera Panning

A camera that slightly pans to where your mouse is on my main menu. Ive seen the posts on the devforum here but none of them seem to work. Here is what ive currently got:

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

    local rs = game:GetService("RunService")

    local fractionToPointAtMouseDestination = 0.5 -- halfway between

    local mousep = mouse.Hit.p

    local camera = workspace.CurrentCamera

    rs.RenderStepped:Connect(function()

    local portion = CFrame.new(camera.CFrame.p, camera.CFrame.p + (mousep - camera.CFrame.p).Unit)

    camera.CFrame = CFrame.new(camera.CFrame.p, camera.CFrame:Lerp(portion, fractionToPointAtMouseDestination).p)
 end)```
it just doesnt work. No errors though.

mousep doesn’t get updated, it just gets set to mouse.Hit.p once and that’s it

Try to do it in a loop, so you’ll make sure that this function will be
updating anytime.

the function is connected to game:GetService("RunService").RenderStepped, which is being fired every time the game renders. So it’s already a loop, the problem is that mousep isn’t in there

1 Like

right but, how do i fix it?
thirtycharacters

put the local mousep = mouse.Hit.p line inside the function connected to RenderStepped

still doesnt work, also no errors.

where did you put this LocalScript? and can I see the properties of your Camera instance?

Its in startergui, and also my cameras cframe is made to go to part but its not a loop, so i shouldnt really affect anything.

To be honest, besides making sure the CameraType is Enum.CameraType.Attach and not making the CFrame go to part, I don’t know what could be causing the issue :confused:

hm. i dont know. ill look around, thanks for the help

1 Like