I am making a 3D menu for a game im working on, and I want to make a background for it, which contains a surfaceGUI with a frame in it, which is the background.
How would I make this part scale perfectly to the player/clients screen?
-- These values are the size that fits the screen with FOV 1 and Distance 1
-- initialX = 0.0175 for screen size 500
-- Tested with screensize being 1393x600
local initialX = 0.045 -- The accuracy is between +- 0.004
local initialY = 0.0174 -- The accuracy is between +- 0.0002
local FOV = 70
local Distance = 10 -- Distance between object and camera on Z axis
local newX = initialX * (FOV * Distance)
local newY = initialY * (FOV * Distance)
newX += newX * 0.87
newY += newY * 0.87
object.CFrame = cam.CFrame * CFrame.new(0, 0, -Distance) -- Assuming you are setting object CFrame Manually
object.Size = Vector3.new(newX, newY, 1)
There, my formula is pretty bad and could be upgraded, but i wont spend like 3-4 hours counting pixels to perfectly fit the screen