Working Security Camera, need help!

For the monitor screens, I used ViewportFrame Handler - Custom updating objects & humanoids in VPFs and put it on a surface gui. When they click into it, you can just set their camera’s position. If you’re doing it this way (i.e. viewport frames for a real time monitor i.e. a tablet tool that you can hold and walk around with but has live feed you can see in first person) I would suggest heavily optimizing it. Make all anchored parts not update, there’s no need, and make a dynamic system that only renders stuff in the camera’s field of view, and removes anything that went out of view, including characters. It’s also important to make this not render when the localplayer can’t see the monitor, because that’s a waste of resources.

You can use something like

function partInFieldOfVision(Part)
    local vector = (Part.CFrame.Position - camera.CFrame.Position)
    local magnitude = vector.Magnitude
    if magnitude > cameraRange then return false end
    local dir = vector.unit
    local angle = math.deg(math.acos(camera.CFrame.LookVector:Dot(dir)))
    return angle < fov
end

If you define fov, cameraRange and camera somewhere, this should work to see if a given part is within cameraRange and inside fov. I use this same logic to test for seeing if a player can see a part within a given range and fov, but the logic still applies.

Of course, if you just want a camera that you click into and lose control of your character, it’s as simple as setting the camera’s type to scriptable (you must set a camera subject beforehand) and then its cframe. To change it back, set the camera type to custom and set the subject to the player’s humanoid. The wiki page about CameraTypes goes over how to make a cutscene, we want the same effect, just without the moving parts (Camera | Roblox Creator Documentation).

Here’s what it looks like in game on a screen

2 Likes