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

How do I position a camera to one position?

Asked by 5 years ago
Edited 5 years ago

In the script it is supposed to position the players camera to a Part named "CameraPart" and make the cameras type scriptable. This does not seem to work. Any help?

local cam = workspace:WaitForChild("Camera")
local camp = workspace:WaitForChild("CameraPart")
cam.CameraType = "Scriptable"
cam.CameraSubject = workspace.CameraPart

2 answers

Log in to vote
1
Answered by
Cyrakohl 108
5 years ago

So basically what you'll need to do is set the camera coordinate frame to the parts cframe as following:

local cam = workspace:WaitForChild("Camera")

local camp = workspace:WaitForChild("CameraPart")

cam.CameraType = "Scriptable"

cam.CameraSubject = workspace.CameraPart
cam.CoordinateFrame = camp.CFrame

0
Dude thanks so much! ReallyUnikatni 68 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

LocalScript

local cam = workspace.CurrentCamera
local camp = workspace:WaitForChild("CameraPart")

cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = camp
cam.CFrame = camp.CFrame
cam.FieldOfView = 70 -- This is optional

For a local player, you need to use the "CurrentCamera", which you cannot use :WaitForChild() on (without creating an infinite yield)

Next, to prevent glitches, use the Enum of the CameraType rather than the string (even though it will work most times)

Finally, the camera's CFrame needs to match the part's CFrame so they are not too far away from each other, otherwise, the camera stays in place but changes its orientation only to match the CameraSubject

Answer this question