Create my backround to be blurry when the GUI is toggled to true!
What is the issue?
The blur is not added nor subtracted, but the prints are working!
I have no errors in my output? Any help would be great
What solutions have you tried so far?
I’ve been trying to figure out soltuons for about an hour now and I’ve tried everything I have seen on the dev forum.!
local blur = Instance.new("BlurEffect")
blur.Size = 0.15
blur.Parent = game:GetService("Lighting")
local GUI = script.Parent
local ToggleButton = GUI.ToggleButton
local MainMenu = GUI.MainMenu
local menutoggled = false
ToggleButton.MouseButton1Click:Connect(function()
if menutoggled == false then
local currentbluramt1 = game.Lighting.Blur.Size
local stopbluramt1 = 22
while true do
print("hi im looping")
wait(0.01)
currentbluramt1 = currentbluramt1 +1
if currentbluramt1 == stopbluramt1 then
break
end
end
MainMenu:TweenPosition(UDim2.new(0.165, 0,0.161, 0))
menutoggled = true
else if menutoggled == true then
local currentbluramt1 = game.Lighting.Blur.Size
local stopbluramt1 = 0.15
while true do
print("hi im looping")
wait(0.01)
currentbluramt1 = currentbluramt1 -1
if currentbluramt1 == stopbluramt1 then
break
end
end
MainMenu:TweenPosition(UDim2.new(0.165, 0,1.1, 0))
menutoggled = false
end
end
end)
Did you notice that your blur size is 0.15? This may not be the real issue, but it could definitely be why your loops are so long. And by so long I mean infinitely long.
I suggest you set the blur.Size to 0 or 1, as your script insists on adding 1 and waiting for it to reach 22. However, if it remains as a decimal, it will reach 22 as intended, but with a decimal at the end. That is obviously not 22, so it will continue for eternity.
EDIT: Adding onto this, you can’t reach the blur size of 0.15 by subtracting 1 from 22, no matter how many times you do this.
Your value, currentbluramt1, is being set to the blur size. Now, look at the line below:
currentbluramt1 = currentbluramt1 +1
Now, currentbluramt1 is told to add a number to its current value. For example, if the blur size was initially 2, it is now 3.
Notice, however, there is no line that assigns this value to the blur size. How do you expect to change the blur size if there is no line that does this? If you look at each loop, you are gathering the necessary values, sure, but you are forgetting to modify the existing blur.Size to its new value. Here is your corrected code:
local blur = Instance.new("BlurEffect")
blur.Size = 0 --- No decimals.
blur.Parent = game:GetService("Lighting")
local GUI = script.Parent
local ToggleButton = GUI.ToggleButton
local MainMenu = GUI.MainMenu
local menutoggled = false
ToggleButton.MouseButton1Click:Connect(function()
if menutoggled == false then
local currentbluramt1 = game.Lighting.Blur.Size
local stopbluramt1 = 22
while true do
print("hi im looping")
wait(0.01)
currentbluramt1 = currentbluramt1 +1
blur.Size = currentbluramt1 --- There!
if currentbluramt1 == stopbluramt1 then
break
end
end
MainMenu:TweenPosition(UDim2.new(0.165, 0,0.161, 0))
menutoggled = true
else if menutoggled == true then
local currentbluramt1 = game.Lighting.Blur.Size
local stopbluramt1 = 0 --- Not in here.
while true do
print("hi im looping")
wait(0.01)
currentbluramt1 = currentbluramt1 -1
blur.Size = currentbluramt1 --- Rinse, repeat.
if currentbluramt1 == stopbluramt1 then
break
end
end
MainMenu:TweenPosition(UDim2.new(0.165, 0,1.1, 0))
menutoggled = false
end
end
end)
local lighting = game:GetService("Lighting")
local blur = Instance.new("BlurEffect")
blur.Size = 0.15
blur.Parent = lighting
local GUI = script.Parent
local ToggleButton = GUI:WaitForChild("ToggleButton")
local MainMenu = GUI:WaitForChild("MainMenu")
local menutoggled = false
ToggleButton.MouseButton1Click:Connect(function()
if not menutoggled then
local stopbluramt1 = 22
while task.wait() do
blur.Size += 1
if blur.Size >= stopbluramt1 then
blur.Size = 22
break
end
end
MainMenu:TweenPosition(UDim2.new(0.165, 0,0.161, 0), "Out", "Quad", 1)
task.wait(1)
menutoggled = true
elseif menutoggled then
local stopbluramt1 = 0.15
while task.wait() do
blur.Size -= 1
if blur.Size <= stopbluramt1 then
blur.Size = 15
break
end
end
MainMenu:TweenPosition(UDim2.new(0.165, 0,1.1, 0), "Out", "Quad", 1)
task.wait(1)
menutoggled = false
end
end)
If you need any assistance with the explanation to any changes made feel free to ask.