Skip to content

Instantly share code, notes, and snippets.

View Validark's full-sized avatar
🍳

Niles Salter Validark

🍳
View GitHub Profile
-- black frames not included
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local Module = {}
Module.Position = UDim2.new(0, 0, 0, 0)
local camera, cameraChanged
local viewport, viewportChanged
-- Challenge:
-- 1. Make `camera' always point to the the current or last known camera.
-- a. Problem: CurrentCamera can be nil.
-- b. Guarantee that `camera' is never nil.
-- 2. Make `viewport' always be the current actual size of the viewport.
-- a. Problem: ViewportSize can falsely report (1,1) before it gets fixed up by RenderPrepare.
-- b. Guarantee that `viewport' is never (1,1).