I made a camera display using just textboxes

So here’s a bit of a fun one. I got annoyed that there was no option to place a camera and render the output to a gui that I can slap on something so I made my own.

This top one is taken at 300x300 scale=2


In the Video it’s taken at 50x50 or 75x75 at about 12 ~ 8 scale respectively
Youtube Video

Place to view if you don’t feel like dropping in the script:
https://www.roblox.com/games/5869947311/DrTest

How it works:
Based of a resolution in the config area it’ll generate that many textbox “pixels” into a frame
After that it’ll use camera:ScreenPointToRay and raycast to a distance to determine a part color then set the “pixel” to be that color

Here’s the script as of this post, you should be able to drop this into starterscripts and it’ll work

local RunService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera

-----Config-------------------------------------------------------------
res = Vector2.new(75,75) 	--set resolution for display, Roblox WILL break at about 80k pix ~285x285
drawdistance = 300 			--How far away will something be drawn
scaledisplay = 8 			--scale the display
displayAnchor = Vector2.new(0.5,0.5)	--where you want the diplay to be
displayPos = UDim2.new(0.5,0,0.5,0) 	--^^^^^^
-----------------------------------------------------------------------
wait(5)

spacer = Vector2.new(1/res.X,1/res.Y)

--screenPart = workspace.guiscreen
--screenPart.Size = Vector3.new(res.X*0.05,res.Y*0.05,1)

gui = Instance.new("ScreenGui")
--gui.SizingMode = Enum.SurfaceGuiSizingMode.FixedSize
--gui.CanvasSize = res
gui.Parent = player.PlayerGui

--setup the frame they will be in
frame = Instance.new("Frame")
frame.Active = true
frame.Size = UDim2.new(0,res.X*scaledisplay,0,res.Y*scaledisplay)
frame.AnchorPoint =  displayAnchor
frame.Position = displayPos
frame.BackgroundTransparency = 0.9
frame.BorderMode = Enum.BorderMode.Inset
frame.BorderSizePixel = 0
frame.Parent = gui

--setup the "pixle"
pixle = Instance.new("TextBox")
pixle.Size = UDim2.new(spacer.X,0,spacer.Y,0)
pixle.Text = ""
pixle.BorderMode = Enum.BorderMode.Inset
pixle.BorderSizePixel = 0 

--generate the pixles
rando = Random.new()
for iY=1,res.Y,1 do
	wait()
	for iX=1,res.X,1 do
		local newpix = pixle:Clone()
		newpix.Position = UDim2.new(spacer.X*iX,0,iY*spacer.Y,0)
		newpix.BackgroundColor3 =  Color3.new(rando:NextNumber(),rando:NextNumber(),rando:NextNumber())
		newpix.Parent = frame
	end		
end

--update the pixles by casting rays
allPixles = frame:GetDescendants()
RunService.RenderStepped:Connect(function()
	for _,pix in ipairs(allPixles) do
		local unitRay = camera:ScreenPointToRay(pix.AbsolutePosition.X,pix.AbsolutePosition.Y)
		--add direction to unit ray
		unitRay = Ray.new(unitRay.Origin,unitRay.Direction*drawdistance)

		local result = workspace:Raycast(unitRay.Origin, unitRay.Direction)
		if result then
			pix.BackgroundColor3 = result.Instance.Color
		else
			pix.BackgroundColor3 = Color3.new(0,0,0)
		end
	end
end)

NOTE

  • Roblox coregui WILL break and disappear at about 80k pix ~285x285
  • unless you like remembering the days of a Core2 Duo, I would stay below 150x150 (best results 50x50 )

Limitations:
Currently uses camera:ScreenPointToRay and the absolute pos of the pix to cast the ray
Which means it has to be on your screen or faked to your screen. Though I’m sure with some clever coding this can be over come.

7 Likes