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

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

Asked by 8 years ago

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)
0
Edited my answer. XAXA 1569 — 8y

1 answer

Log in to vote
1
Answered by
XAXA 1569 Moderation Voter
8 years ago

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
0
When I put this in, as a localscript in starterpack, nothing happened still, it was like a normal camera, moved with player. CheekySquid 78 — 8y
0
Add a wait(1) at the beginning of the script. The Camera hasn't loaded yet. XAXA 1569 — 8y
Ad

Answer this question