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

Locking The Camera To A Part?

I am attempting to lock the camera to a part but I am a little lost on what to do. Heres what ive got so far.

local cam = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Camera1 = game.Workspace.Camera1
-------------------------------------------------------------------
cam.CameraType = Enum.CameraType.Scriptable
if workspace.Cameras.Camera1 then
cam.CFrame = CFrame.new(Camera1.CFrame.X, Camera1.CFrame.Y + 1.5, Camera1.CFrame.Z + 13)
-------------------------------------------------------------------

I am lost why this isnt working.

1 answer

✓ Accepted answer

I've fixed up your script, the problems were:

  • You didn't set the subject.

  • Nothing else happened, all that happened was that you could freely move your camera because it was set 'Scriptable' the line 6-7 didn't do anything.


  • Hopefully this'll work.
local cam = workspace.CurrentCamera
local Camera1 = game.Workspace.Cameras.Camera1

cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = Camera1
 
-------------------------------------------------------------------

while wait() do
    cam.CoordinateFrame = CFrame.new(Camera1.Position)
end

-------------------------------------------------------------------

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