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

How do i make the camera unmoveable? (You can't move the camera around)

The part named CamPart is in the air, the part named Detector is on the ground. Im trying to make it so you are in the middle of CamPart, looking down on Detector, and you can't move the camera. My Code:

local cam= game.Workspace.CurrentCamera
while wait() do
cam.CameraType="Fixed"
cam.CameraSubject=game.Workspace.CamPart
cam.Focus=game.Workspace.Detector.CFrame
end

1 comment

0

Set the CameraType to Enum.CameraType.Scriptable

2 answers

✓ Accepted answer

I have a similar script, where I want the camera to be in a fixed position:

local cam = workspace.CurrentCamera

cam.CameraType = "Scriptable"
cam.CFrame = CFrame.new(117.350388, 55.271347, 120.202576,
	 0.00612254534, -0.777157724, 0.629276335,
	 -2.32830644e-10, 0.629288197, 0.777172208,
	 -0.999981344, -0.00475827185, 0.0038528447)

Having the CameraType set to "Scriptable" means that you cannot do anything to it using the default options, and you would have to script your own functionality, or you can just leave it and have it not do anything

To get the large CFrame value I just aligned my camera where i wanted it to be in the Editor and printed the CFrame value in the command line:

print(workspace.CurrentCamera.CFrame)

I hope this helps you :)

3 comments

0

THAT IS SO EASY! WHY DID I NOT THINK OF THAT! LOL THANKS!

0

Haha, someone beat me to the punch. Good post.

0

I had the same problem with this too, so I decided to help as I already knew the answer :)

If you want to create custom functionality for your camera, you need to make it Scriptable. This permits you to control the camera by means of a script.

If you want the Camera to be positioned inside of another part, set the Camera's CFrame to the other part's CFrame.

If you want the Camera to look toward an model, part, or humanoid in the world, you can set its CameraSubject to that Instance.

If you want to ensure that the frame that the Roblox client renders every cycle is up to date, you should set the Camera's Focus; a point in 3 dimensional space around which the Roblox Engine begins updates first, to ensure that longer rendering operations elsewhere in the world do not prohibit the rendering of the Camera's viewport.

Based on that, this script should provide the functionality that you are looking for:

local camera = game.Workspace.CurrentCamera;
while wait() do
	camera.CameraType = "Scriptable";
	camera.CFrame = game.Workspace.CamPart.CFrame;
	camera.CameraSubject = game.Workspace.Detector;
	camera.Focus = game.Workspace.Detector.CFrame;
end

2 comments

0

Explain what you're doing

0

Fair enough. Better?

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