How would I make a security camera display on a block, instead of in a GUI

I cant find any documentation on how I would make a block which acts like a security monitor.

check out ViewportFrame!
it’s a rough version of copying what a camera/view sees into a GUI frame, but it’s very basic and probably won’t duplicate what you want to do. youd have to rebuild everything into the “viewport” (since it is its own “world”) and the lighting isnt very good.

but theres two different ways you could go around this limitation that roblox has:

  1. give the camera a “no signal” effect, but allow the player to “zoom in” to the camera to look. you would instead be using the player’s camera to look around the map, and you don’t need to add anything other than what’s already there for the player to see.

  2. get some pre-rendered images of where the camera is going to look, and set it as a GUI image background. any figures you want to put over it, you can overlay together in layers.
    if there’s going to be some dynamic things actively moving in it though (ex. players), you might want to combine it with a ViewportFrame and make some code that copies the players’ position to the viewport’s world.

not too much to choose from though since roblox is limited in the power it can use. it has to be able to support both PC and tiny mobiles that warm up to the temperature of the sun, of course.
good luck!

im using it for a CCTV purpose though (to monitor a level crossing) so idk what is possible, the first option could work

yeah, it depends on how much activity you expect to be happening in the monitor. if its just still images, the second option works best (since it’s hard to replicate actual roblox lighting to ViewportFrames. but if you aren’t concerned about the players needing to have mobility and not be locked in after zooming into a camera, then number 1 is easiest to do! ;D

well the camera is located in a signal box which needs mobility (as the signaller will be watching many trains), and they need to see any cars or trains which are moving - so neither solution seems too good

I wouldn’t recommend using ViewportFrames. They’re hard to work with and are bad for performance. You’d need to use a loop to continuously update the ViewportFrame, and that can be taxing.
I’d rather use a block that when clicked sets the player’s camera to the CCTV.
If you absolutely need to use ViewportFrames, display it only to the signaller (and perhaps other players in the signal box). Update it on the client (in a localscript). Have it enabled only when the level crossing lowers (just like IRL), until the signaller confirms that the crossing is clear, after which you would disable it.
PS, I’m a fellow railway game developer.

2 Likes

im not too sure how you would implement it in a way that doesent seem unrealistic

You may used a ‘.Renderstepped’ event which sets the player camera cframe to the cframe of a part acting as the camera. If you want the actual monitor to show the CCTV camera area then using a viewport frame would be your best option but i wouldn’t recommend that