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 a part be the camera?

I have a part in Workspace, it is called CameraPart. I want the camera to look through CameraPart. I do not know if I should use a server script or a local script. I have made a script, but it does not work. It is a server script, here it is:

game.Workspace.CameraPart = game.Workspace.Camera

2 answers

✓ Accepted answer

The problem is that when you're handling something that you want to happen for the player only you should be using a local script, not to mention that the code you provided/written was incorrect. You should be manipulating the CFrame/CameraSubject of the CurrentCamera (an object located in the workspace).

wait(.25)
local CurrentCamera = workspace.CurrentCamera
local Part = workspace.CameraPart

CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = Part.CFrame

In the code above we have two variables declared, one for the CurrentCamera and another for a part. We change two things of the CurrentCamera, one for the CameraType property and another for changing the CFrame of the CurrentCamera. We change the CurrentCamera to scriptable and then afterwards we change the CurrentCamera's CFrame to the Part's CFrame. That's about it.

If you want it so the Camera to be reverted back to normal, change the CameraType to CurrentCamera.CameraType = Enum.CameraType.Custom since custom is the CameraType by default.

5 comments

0

Oh and another thing is that you can either put this local script in StarterGui or StarterPlayerScripts.

0

Thank you so much!

0

One question, how do I make the camera move once the leaderstats value changes?

0

Like if the leaderstats is at 1, then the camera stays at one position or CFrame, if the leaderstats is at 2, then it is at another position or CFrame.

0

Do a conditional statement that checks the value of the integer.

It needs to be a localscript.

game.Players.LocalPlayer.CurrentCamera.CameraSubject = workspace.CameraPart

We get the Local Player's "Current Camera( which can only be called from a LocalScript.)", then makes the cameras subject the Camera Part.

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