Hello, Recently I and a friend have been working on an open source Blur effect that enables when the Menu is opened/closed, and I was wondering if anyone could give me feedback, I have been having some errors in this script as well, this includes when the player spams the Menu, sometimes the blur does not show, I would like it if someone could tell me how to fix it, I already have a debounce in place.
local Lighting = game:GetService("Lighting")
local Blur = Lighting.Blur
local TweenService = game:GetService("TweenService")
local isMenuOpen = false
local isTweening = false
local blurTween
local function toggleBlur(enabled)
if isTweening then
return
end
isTweening = true
if blurTween then
blurTween:Cancel()
end
if enabled then
Blur.Enabled = true
blurTween = TweenService:Create(Blur, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = 20})
blurTween:Play()
else
blurTween = TweenService:Create(Blur, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = 0})
blurTween:Play()
blurTween.Completed:Wait()
Blur.Enabled = false
end
isTweening = false
end
GuiService.MenuOpened:Connect(function()
if not isMenuOpen then
isMenuOpen = true
toggleBlur(true)
end
end)
GuiService.MenuClosed:Connect(function()
if isMenuOpen then
isMenuOpen = false
toggleBlur(false)
end
end)