Advertisement
Limesey

Roblox UI Blur

Dec 12th, 2019
1,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local lighting = game:GetService("Lighting")
  2.  
  3. local blur = lighting:FindFirstChildOfClass("BlurEffect")
  4. local blurSize -- variable to store the default blur value
  5. local open = false -- variable to store whether the GUI is open or not
  6.  
  7. local function setup()
  8.     if(blur) then
  9.         blurSize = blur.Size -- store the default blur value if instance "Blur" already exists
  10.     else
  11.         blur = Instance.new("BlurEffect")
  12.         blur.Parent = lighting
  13.         blur.Size = 0
  14.     end
  15. end
  16.  
  17. local function openUI()
  18.     blur.Size = 15 -- Any value of your choice, I'm using 15
  19.     open = true
  20. end
  21.  
  22. local function closeUI()
  23.     if(blurSize) then -- if we have a default blur value
  24.         blur.Size = blurSize
  25.     else
  26.         blur.Size = 0 -- we keep the blur effect, but give it size 0
  27.     end
  28.  
  29.     open = false
  30. end
  31.  
  32. setup() -- we run the setup function to store the default value, and whatever else you want;
  33.    
  34. --[[
  35. Usage example:
  36.  
  37. button.MouseButton1Click:Connect(function()
  38.     if(open) then
  39.         closeUI()
  40.     else
  41.         openUI()
  42.     end
  43. end)
  44. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement