How do I scale a screen GUI based off the cameras current position?

Im working on a small little project right now. And Im trying to achieve a effect like in this clip.
Clip

The background is blurred out and darkened, the player has emphasis and the effect isnt affected by this blurring.

What im using to achieve this is viewport frames to render the player on a GUI, and ColorCorrection to blur the background. What im having trouble with is the effect. Im using a ScreenGui for the effect that sets its position to the target part. Only thing im having issue with is the scaling. When I zoom out, it grows. but when i zoom in, it shrinks. How could I make it so it shrinks when i zoom out/move away and grow when I zoom in/move closer? Thanks in advance!

EDIT: Actually, the size of the UI doesnt change at all. But I have no idea how to scale it based off my cameras zoom and the players distance from the target part.

Issue:
Issue

Code:

while true do task.wait()
	local vectors, onscreen = game.Workspace.Camera:WorldToScreenPoint(workspace.OrbThing.Position)
	script.Parent.Position = UDim2.fromOffset(vectors.X,vectors.Y)


end
1 Like

bumping this, still need help!

you can probably use a billboard gui with offset scaling to achieve the same effect

the size should be 1/distance though

Yeah I tried using billboard GUI’s the issue is that it would be affected by lighting. And I have no idea if theres a option to disable it. And I cant put the billboard GUI over the screengui.

There is a property called LightInfluence or something like that.

also, it isn’t shrinking or growing. it isn’t changing size at all.

1 Like

Can I see the properties of the UI itself, namely the size, while runtime probably.

Oh yeah you’re right, im just now realizing it

The size stays the same which I just recently found out. Heres the rest of the UI if theres anything of note there though.
image

1 Like

the size should be {1,0}{1,0}, this size will take up ur entire screen but just lower the values until its good. something like {0.5,0}{0.5,0} would be good for example.

Have you tried using the FieldofView property in your code to set the zoom level of the GUI and scale it accordingly?