Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't the camera lock onto the part in this script?

This should look out from a part called CamPart at a Part called FocusPart, instead it just looks at the CamPart from far away.

This is a LocalScript in StarterPack

game.Workspace.CurrentCamera.CameraType = "Scriptable"
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.CamPart
game.Workspace.CurrentCamera.Focus=CFrame.new(-13, -54.5, 40)

1 comment

0

Edited my answer.

1 answer

From the wiki page for CameraSubject: A Model, Part, or Humanoid for the camera to look at. Setting this property will override the Focus property. Furthermore, neither CameraSubject nor Focus will work at all when the CameraType is set to Scriptable.

To make this work properly, set the CameraType to Scriptable, then set its CoordinateFrame to a CFrame starting at CamPart, looking at FocusPart.

wait(1)
local Camera = game.Workspace.CurrentCamera
local CamPart = game.Workspace:WaitForChild("CamPart")
local FocusPart = game.Workspace:WaitForChild("FocusPart")

Camera.CameraType = "Scriptable"
Camera.CoordinateFrame = CFrame.new(CamPart.Position, FocusPart.Position) -- constructs a CFrame starting at CamPart, looking at FocusPart

2 comments

0

When I put this in, as a localscript in starterpack, nothing happened still, it was like a normal camera, moved with player.

0

Add a wait(1) at the beginning of the script. The Camera hasn't loaded yet.

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