Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I lock the camera?

How do I fix it at a point and when I'm going to the side(Left) the camera goes to the side with me but you cannot drag the camera and turn it. It should be fixed straight and unable to turn. Do I need lookVector? If I do then can you be kind to give a code? Basically, I want the camera stuck on an angle and you shouldn't be able to move the camera around, it should just follow your character but not rotate. So when you hold right click you should be able to move the camera.

1 answer

✓ Accepted answer

First off, use local scripts to use the camera. Next, we have to change the camera type.


This is for not being able to move the mouse left and right, but you can change the camera to move up and down.

--local script
workspace.Camera.CameraType = "Attach"

To make it unable to move at all, we can make the camera type scriptable. Then we need a loop to update or something.

--Local Script, this is an idea, it's very glitchy.
local hrp = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart
workspace.Camera.CameraType = Enum.CameraType.Scriptable
workspace.Camera.CameraSubject = hrp.Parent.Head
game:GetService("Players").LocalPlayer.CameraMaxZoomDistance = 0.5

game:GetService("RunService").RenderStepped:connect(function()
    workspace.Camera.CoordinateFrame = hrp.Parent.Head.CFrame
    * CFrame.Angles(math.rad(hrp.Rotation.X),math.rad(hrp.Rotation.Y),math.rad(hrp.Rotation.Z))
end)


Hope it helps!

2 comments

0

Why not use RenderStepped?

0

@ M39a9am3R , Good idea...

This discussion is preserved as it was. New answers, comments, and votes are closed.