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 position a camera to one position?

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

✓ Accepted answer

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

1 comment

0

Dude thanks so much!

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

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