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

How do you make the camera go inside of a part?

Asked by
PolacW 0
5 years ago

I have been trying to make the camera go inside of a object but it doesn't move to that object.

local c = workspace.Camera
local cc = workspace.CurrentCamera
c.CameraSubject = workspace.Gadgets.Model.Part2
c.CameraType = "Scriptable"
cc.CameraSubject = workspace.Gadgets.Model.Part2
cc.CameraType = "Scriptable"

I put that code in a localscript inside of StarterGui. Help please.

0
cc.Parent = workspace.Gadgets.Model.Part2 User#24403 69 — 5y
0
pretty epic User#24403 69 — 5y
0
local cc = workspace.CurrentCamera; cc.CameraType = Enum.CameraType.Scriptable; cc.CFrame = workspace.Gadgets.Model.Part2.CFrame Rheines 661 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Local Script

local player = game.Players.LocalPlayer
local part = workspace.Gadgets.Model.Part2

local c = workspace.Camera
c.CameraSubject = workspace.Gadgets.Model.Part2
c.CameraType = Enum.CameraType.Scriptable

local cc = workspace.CurrentCamera
cc.CameraSubject = workspace.Gadgets.Model.Part2
cc.CameraType = Enum.CameraType.Scriptable

player.CameraMode = Enum.CameraMode.LockFirstPerson

If you've seen the Camera Modes in the player (Default is Classic), the second option, as depicted above, is "LockFirstPerson" which will put the camera in the POV of the Part you're changing the camera subject to (Doing this with the normal player will place the camera CFrame within the player's Head).

I recommend doing this after you've set the camera subject, or else it will occur too early. The only drawback to this is that the mouse cannot freely move around the screen, and must stay in the center.

Also, using the CameraType's Enum is better to prevent glitches, even though the string itself usu. works.

Ad

Answer this question