Depth of Field partially working, what did I wrong?

Hello there,
yesterday I experimented with the new Depth of Field Instance. It is very nice, however I am running in some problems.
Currently, Depth of Field does work in 40% of tries, without any script changes in between.
As I want DoF to be animated (tweened) when an event has been fired, I instance it and put it into the local camera. Afterwards, I set all values to 0 and use TweenService to tween them to default.
It does tween and work, however it sometime does not.

Here is my code (not complete):

--there is other script before it, this is inside a LocalScript in StarterGui.
local tweenService = game:GetService("TweenService")
local cam = workspace.CurrentCamera 
local DOF ="DepthOfFieldEffect", cam)
						cam:WaitForChild("DepthOfField", 1000)
						DOF.FarIntensity = 0
						DOF.FocusDistance = 0
						DOF.InFocusRadius = 0
						DOF.NearIntensity = 0
						local tween2 = tweenService:Create(
							DOF,, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
								FarIntensity = 0.75,
								FocusDistance = 0.05,
								InFocusRadius = 10,
								NearIntensity = 0.75
						print("done")  --is being printed everytime, regardless of it working or not.

If you want to test it, you can do that here (simply click the screen):

Once you clicked you can not get out of the screen anymore (I am working on it, it is early WIP). Simply rejoin and look if the issue is still existing for you.

Thank you in advance. It is my first time working with camera filters, so pls bare with me.

Edit1 and 2: Added variables to the script, forgot to add them (pls less confusion)


Hey there!
First things that comes into my head is the fact you may be applying the effect on game.Workspace.Camera and not on game.Workspace.CurrentCamera. Are you sure the cam variable stands for game.Workspace.CurrentCamera?

Yes it is addressing workspace.CurrentCamera, forgot to add in code snippet.

1 Like

tweenService is not a service and is just an unknown global until you write game:GetService("TweenService"):Create() or create a var above the unknown global

1 Like, parent) is deprecated use NewInstance.Parent = parent instead :slight_smile:

1 Like

As far as I know it is not deprecated and is very much fine to use

tweenService is a variable I have, it gets it as a service. Forgot to add that sorry. (It is a code snippet)

Never ran into the issue when I was instancing (even in complex UI scripts where one script built a large UI).

Updated the Script snippet. Basically the camera tween always works, however DoF does not and fail regularly.

That code should work 100% of the time. Could you elaborate on what you mean by the Camera Tweens but the Depth of Field Effect object doesn’t? If your Camera becomes blurry then the object tween was successful and the code works.

Keep in mind that Depth of Field doesn’t work if you have low graphics, studio or in-game.


Sure. Before the code snippet, I tween the camera (CurrentCamera) so you have the screen in front of it (as visible in test game). Afterwards, the code snippet runs. It always logs “done” in Client Console.

What does only work partially is the DoF.

1 Like

That could be it. I have my settings on auto.
However the game is kinda small.

Gonna test it tomorrow with highest graphics, maybe that will help.

Marked as solution. The issue was my graphics settings.

Thanks for all devs helping in this thread.