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

Camera script is displaying the camera below the map?

Asked by
gitrog 326 Moderation Voter
6 years ago

Not quite sure how cameras work. I try to display the camera as shown below, but the view is below the map.

--Setup variables
local cameras = game.Workspace.CCTVCams:GetChildren()
local cameraSelected = 1
local camera = game.Workspace.CurrentCamera

--Function to update the camera
local function updateCam(camNum)
    local camPart = cameras[camNum].CamPart
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CameraSubject = camPart

    camera.CoordinateFrame = CFrame.new(camPart.Position)
    camera.Focus = CFrame.new(camPart.Position)
end

updateCam(1)
0
I havent worked with cameras to much, but ill recommend two things. One, change the function to a renderStepped function. That way it runs on FPS not time. And second remove camera.Focus ive personally never had any luck with it. Also change "camera.CoordinateFrame" to "camera.CFrame" GottaHaveAFunTime 218 — 6y

1 answer

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
6 years ago
--Setup variables
local cameras = game.Workspace.CCTVCams:GetChildren()
local cameraSelected = 1
local camera = game.Workspace.CurrentCamera

--Function to update the camera
local function updateCam(camNum)
    local camPart = cameras[camNum].CamPart
   local target = camPart
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = camPart

cam.CoordinateFrame = CFrame.new(target.Position)
end

updateCam(1)

Try using this.

Ad

Answer this question