The code I currently have doesn’t include not having a Blur within a zone, nor is it functional in the first place.
local camera = game.Workspace.CurrentCamera
local part = game.Workspace.PlayerSpawn
local depthOfField = Instance.new("DepthOfFieldEffect")
depthOfField.Enabled = true
depthOfField.Parent = camera
local maxBlur = 10
local maxDistance = 50
while true do
local distance = (part.Position - camera.CFrame.Position).Magnitude
local blurIntensity = math.min(distance / maxDistance, 1) * maxBlur
depthOfField.FocusDistance = distance
depthOfField.InFocusRadius = blurIntensity
wait(0.1)
end
I’ve used the AI Assistant, however I knew that wouldn’t work when it told me to put a LocalScript in ServerScriptService
The DepthOfFieldEffect simulates a camera lens by blurring parts of a scene not in focus. Distant objects can be blurred or this effect can be used to focus on specific parts of a scene, like an item in an in-game shop.
Try playing around with it.
By the way, Localscripts don’t work in ServerScriptService.
That code from AI Assistant definitely doesn’t work.
Create a LocalScript and place it in StarterPlayerScripts.
Insert this code:
local part = game.Workspace:WaitForChild("SpawnLocation")
local player = game.Players.LocalPlayer
local camera = player
local blurEffect = Instance.new("BlurEffect")
blurEffect.Parent = game.Lighting
blurEffect.Enabled = true
blurEffect.Size = 0
while task.wait(0.1) do
local distance = (part.Position - player.Character.HumanoidRootPart.Position).Magnitude
blurEffect.Size = distance
end