Help with a blur effect script

so, for some reason, the blur effect isn’t destroying itself.

-- WHEN PLAYER LOADS --

function player_LOAD  ()
	local blur = Instance.new('BlurEffect', game.Lighting)
	blur.Size = 100
	
	local info =  game.Players.LocalPlayer.PlayerGui.Main.Using.Button
	local Main1 = game.Players.LocalPlayer.PlayerGui.Main

-- STATING WHAT HAPPENS WHEN YOU CLICK INFO --

	info.MouseButton1Click:Connect(function()
	wait(0.01)
	blur:Destroy() -- DESTORYS WHICH DOESNT WORK 
end)
end
player_LOAD() -- END LOADING --
2 Likes

Are you having any errors in your output? Maybe try using Debris:AddItem() instead of :Destroy()

2 Likes

nope, no errors. i tried to do blur.Size = 0 but that didn’t work

2 Likes

Try enable/disabling it, there are similar topics created on this subject.

2 Likes

yeah but like, no it creates it from the script so its not physical

2 Likes

There’s a bad habit you do and its putting a second parameter in the instance. Also try doing game.Lighting.Blur:Destroy()

2 Likes

Is this code only going to be used once? If so, I don’t think it needs to be in a function. And where is the script located?

2 Likes

in a screengui, it’s only used once. (local script)

1 Like

Could you send the hierachy of its location so I can see what service it’s partnered to

1 Like

Can I see your full code (if this isn’t already)? I’ll try doing it myself and see if it works fine for me.

1 Like

I made some changes to the code.

function player_LOAD  ()
	local blur = Instance.new('BlurEffect', game.Lighting)
	blur.Size = 100
	
	local info =  game.Players.LocalPlayer.PlayerGui.Main.Using.Button
	local Main1 = game.Players.LocalPlayer.PlayerGui.Main
	local OnDis = script.Parent -- parent of screengui
	local OnClickd = script.Parent.Using.Skip -- skip button


	info.MouseButton1Click:Connect(function()
	wait(0.01)
		game.Lighting.Blur:Destroy()
		
		wait(2) -- wait 2 seconds before skip button is visible
		
		OnClickd.Visible = true
OnClickd.MouseButton1Click:Connect(function() -- if clicker
OnDis.Enabled = false -- gui is false
game.Lighting.Blur:Destory() -- destorys 
end)
end)
end
player_LOAD()
1 Like

By the way, when blur is created, the name is “BlurEffect” so you should do game.Lighting.BlurEffect:Destroy() instead.

still doesn/t work. i have tried it but i don’t know what’s wrong.

1 Like

I can send you the workspace if you would like that?

image

the script is named “BlurEffect”

1 Like

I cleaned up your code a little, I made it compatible for that LocalScript you are showing in this picture. Tell me if anything goes wrong or if you get any errors:

function PlayerLoad()
	local BlurEffect = Instance.new('BlurEffect', game:GetService("Lighting")); -- Creates the BlurEffect
	BlurEffect.Size = 100; -- Gives the BlurEffect 100 of size

	local Info =  script.Parent;
	local Main1 = game.Players.LocalPlayer.PlayerGui.Main;
	local OnDis = script.Parent.Parent.Parent; -- ScreenGui
	local OnClicked = script.Parent.Parent.Skip; -- Skip button

	Info.MouseButton1Click:Connect(function()
		game.Debris:AddItem(BlurEffect,.01); -- Destroys the blur effect after 0.01 seconds
		wait(2); -- Waits 2 seconds before the skip button is visible
		OnClicked.Visible = true; -- Makes the button visible
		OnClicked.MouseButton1Click:Connect(function() -- If the player clicks then...
			OnDis.Enabled = false -- The GUI becomes invisible
			BlurEffect:Destroy() -- Destroy the blur effect 
		end);
	end);
end;
PlayerLoad();

Sorry for the semicolons at the end of the lines, I’m just too used to use them when I write scripts lol.

1 Like

Perhaps try

local blur = Instance.new('BlurEffect')
blur.Size = 100
blur.Parent = game.Lighting

local gui = script.Parent
local skip = gui.Using.Skip

skip.MouseButton1Down:Connect(function()
	blur:Destroy()
end)

Since you said it only is used once, there’s no need to put in a function, I also placed blur.Parent = game.Lighting and removed the 2nd paramter as it’s slower to do it like that, especially if you change a lot of properties. Also changed MouseButton1Click to MouseButton1Down since I heard the former can not work sometiems