How to make Camera Follow Cursor?

Hello there,
I am attempting to make a script where the camera would follow wherever the cursor goes, whenever a player holds down shift. I am seeking guidance on how I should I approach this idea.

I did thought of using TweenService, but unfortunately I cannot seem to make it work, or perhaps the way I have written it is simply incorrect. Nonetheless some suggestions would be appreciated.

2 Likes

But firstly you need to add CamPart:
image

Then create LocalScript in ScreenGui and paste in it this:

local cam = workspace.CurrentCamera
local mouse = game.Players.LocalPlayer:GetMouse()
local part = workspace.CamPart

cam.CameraType = "Scriptable"

game["Run Service"].RenderStepped:Connect(function()
	cam.CFrame = part.CFrame
	cam.CFrame = CFrame.lookAt(cam.CFrame.Position, mouse.Hit.Position)
end)

for cooler effect you can change

game["Run Service"].RenderStepped:Connect(function()
	cam.CFrame = part.CFrame
	cam.CFrame = CFrame.lookAt(cam.CFrame.Position, mouse.Hit.Position)
end)

to this:

game["Run Service"].RenderStepped:Connect(function()
	cam.CFrame = part.CFrame
	cam.CFrame = cam.CFrame:Lerp(CFrame.lookAt(cam.CFrame.Position, mouse.Hit.Position), 0.2)
end)
2 Likes

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