Is there any way to add a Blur Effect when someone looks at a part?

What do you want to achieve? I want to add a Blur Effect ( using the Blur function in Lighting ) whenever one player ( so client-sided ) looks at a part.

What solutions have you tried so far?

Can’t find any

1 Like

You should use a ray that shoots from the player’s eyes.

1 Like

When player looks the part? when player is near the part and looking at it?

You could use RayCasting, towards the camera point of view, if the ray finds specifically that part, change client side lighting.Blur.

1 Like

You can check if a part is on screen by using the following code.

local Camera = workspace.CurrentCamera

local Part = workspace.Part

local _, visible = Camera:WorldToScreenPoint(Part.Position)

game.Lighting.Blur.Enabled = visible

-- i haven't tested this code, i just wrote it here so idk if it works or not
1 Like

Doesn’t work unfortunately, may have to find another way to do it.

1 Like

Can I see what your code looks like? Maybe I can try to fix it.

1 Like

Basically your code but alright. Apologies, it’s just my first time doing something like this.

Oh ok, I can see the problem now. It needs to be in a loop, this is how you make a loop.

local RunService = game:GetService('RunService')
local Camera = workspace.CurrentCamera

local Part = workspace.Part

RunService.RenderStepped:Connect(function()
    local _, visible = Camera:WorldToScreenPoint(Part.Position)

    game.Lighting.BlurEffect.Enabled = (if visible then true else false)
end)
1 Like

Thank you very much!!! I appreciate it a lot! Any way I can implement the size property aswell? If so, that’d be awesome!

1 Like

Oh I think I have got it

local RunService = game:GetService('RunService')
local Camera = workspace.CurrentCamera

local Part = workspace.Part

RunService.RenderStepped:Connect(function()
    local _, visible = Camera:WorldToScreenPoint(Part.Position)

    game.Lighting.BlurEffect.Enabled = (if visible then true else false)
   game.Lighting.BlurEffect.Size = x
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.