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

How do I make a part be the camera?

Asked by 4 years ago

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

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
4 years ago
Edited 4 years ago

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.

0
Oh and another thing is that you can either put this local script in StarterGui or StarterPlayerScripts. Mr_Unlucky 1085 — 4y
0
Thank you so much! GamingWithFlight 80 — 4y
0
One question, how do I make the camera move once the leaderstats value changes? GamingWithFlight 80 — 4y
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. GamingWithFlight 80 — 4y
0
Do a conditional statement that checks the value of the integer. Mr_Unlucky 1085 — 4y
Ad
Log in to vote
0
Answered by
KDarren12 705 Donator Moderation Voter
4 years ago

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.

Answer this question