How do I make a SurfaceGui fullscreen?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    What I ultimately want to achieve: I want to make a SurfaceGui fullscreen so I can have it blurred with a BlurEffect in the lighting while keeping another GUI on top (in the PlayerGui).
  2. What is the issue? Include screenshots / videos if possible!
    I can not figure out how to adjust the size of a part that is 0.2 studs in front of the camera at all times but also getting the part to the correct size so that it takes up the entire screen.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have done a lot of hacky CFrame manipulation, like adjusting the scale vectors in the camera. I also tried searching the Developer Hub but I could not find anything.

I have tried using GuiEffect script from MakerModelLua’s admin (i modified it to work with what I am doing):

local Transparency = script:WaitForChild("Transparency").Value --@@Transparency@@
local GUIName = script:WaitForChild("GUIName").Value --@@GUIName@@

local Cam = Workspace.CurrentCamera
local GUI = script.Parent:WaitForChild(GUIName)
script.Parent = nil
local Event = nil

local Part = Instance.new("Part", Cam)
Part.FormFactor = "Custom"
Part.Size = Vector3.new(0.2, 0.2, 0.2)
Part.Anchored = true
Part.Locked = true
Part.CanCollide = false
Part.Material = "Neon"
local Mesh = Instance.new("BlockMesh", Part)

local SG = nil
function IsSG(Obj)
	if Obj:IsA("ScreenGui") then
		SG = Obj
	elseif Obj then
		IsSG(Obj.Parent)
	end
end
IsSG(GUI)

Event = game:GetService("RunService").RenderStepped:connect(function()
	local RCF = Cam:GetRenderCFrame()
	local AngleFrame = RCF:toObjectSpace(CFrame.new(RCF.p)):inverse()
	local TopLeftRay = Cam:ScreenPointToRay(GUI.AbsolutePosition.X, GUI.AbsolutePosition.Y, 0)
	local BottomRightRay = Cam:ScreenPointToRay(GUI.AbsolutePosition.X + GUI.AbsoluteSize.X, GUI.AbsolutePosition.Y + GUI.AbsoluteSize.Y, 0)
	local BottomLeftRay = Cam:ScreenPointToRay(GUI.AbsolutePosition.X, GUI.AbsolutePosition.Y + GUI.AbsoluteSize.Y, 0)
	local MidRay = Cam:ScreenPointToRay(GUI.AbsolutePosition.X + GUI.AbsoluteSize.X/2, GUI.AbsolutePosition.Y + GUI.AbsoluteSize.Y/2, 0)
	Part.Transparency = 1--GUI.BackgroundTransparency * 1.25
	Part.Color = GUI.BackgroundColor3
	if workspace.DistributedGameTime > 10 then -- ignore this, pretend its not here, it is hacky programming
		Part.Size = Vector3.new((BottomRightRay.Origin - BottomLeftRay.Origin).magnitude, (TopLeftRay.Origin - BottomLeftRay.Origin).magnitude, (.2))
		Mesh.Scale = Vector3.new(1,1,1)
	end
	Part.CFrame = CFrame.new(MidRay.Origin) * AngleFrame * CFrame.new(0, 0, -0.1)
	
	if not GUI.Parent or not Part.Parent or not SG.Parent then
		Event:disconnect()
		Part:Destroy()
		script:Destroy() script.Disabled = true
	end
end)

and I have got it to work with a part, the part is visible and sized correctly, but it is z-fighting because the part is perfectly at the close part render cutoff, or NearPlaneZ (-0.1) of the camera. However, if you put a SurfaceGui on the part, it will not be visible, since the cutoff distance of SurfaceGui to render is -0.102 or something like that, so it will not render unless you move the part back a bit, but then once you do that, it is not perfectly sized anymore (fullscreen, but 2 pixels on the edges of the screen are missing due to it being moved back like 0.002 studs, and the GUI is distorted and smaller), so does anyone know how to make it so you can get it to appear at 0.2 studs instead of 0.1 and still have the correct sizing so it will fit perfectly on screen?

Things I have tried:

  • Setting the NearPlaneZ of the camera to 0.2 and then getting the correct size of the part and then back, which threw an error, since NearPlaneZ is read-only.
  • Manipulating random values in the Camera’s CFrame.
  • Moving the camera 0.1 studs forward then getting the correct size of the part then back again

TL;DR: I want to have a part that is 0.2 studs in front of the camera at all times but also getting the part to the correct size so that it takes up the entire screen.

Maybe this thread will assist you:

Thanks, I will check the thread out.

I tried the solution, and it covered up more of the screen than was available.
I want it to cover exactly the entire screen, no more, no less.

Change the UI object size to 1

What do you mean by “UI object size”?

https://gyazo.com/ba753755d8b6eb70fb3878f7de5b4060

1 Like

This will get the frame size, to the part size, test it out

1 Like

I’ve already done that.
The problem lies within the part size, not the GUI.