Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I lock the camera?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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!

0
Why not use RenderStepped? M39a9am3R 3210 — 9y
0
@ M39a9am3R , Good idea... EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question