Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I can't get my blur to work when my GUI is enabled/when a key is pressed?

I'm not sure how to make a blur effect work with a keypress?

Any ideas on how I can fix this?

local mouse = game.Players.LocalPlayer:GetMouse()
local gui = game.Players.LocalPlayer.PlayerGui.KD.Main -- replace Frame to the name of the frame your gui is in

mouse.KeyDown:connect(function(key)
    if key ==  "q" then
	 if script.Parent.Parent.Parent.MAIN.Main.Visible == true then
		print("Loading Screen Is Visible!")
	else
		gui.Visible = not gui.Visible
		game.Lighting.BlurMenu.Size = 34
		print("Blur Enabled")
	end
    end
end)

script.Parent.Changed:Connect(function()
	if script.Parent.Visible == false then
		game.Lighting.BlurMenu.Size = 0
		print("Blur Disabled")
end
end)

1 answer

✓ Accepted answer

Hello, Jomeliter!

The following code below should help you out. If you need to know what the code does I tried my best to explain it inside the script!

This should go inside of a LocalScript in the ScreenGui

Edit the script to your liking

local Key = "Q" -- The key they should press to activate the UI

local ScreenUI = script.Parent -- Path to the ScreenGui
local Frame = ScreenUI.Frame -- Path to the Frame

local OnScreen = false -- Using a variable instead of a BoolValue

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input, GPE)
	if not GPE then
		if Input.KeyCode == Enum.KeyCode[Key] then -- If they press the Key then the Frame will show
			if not OnScreen then -- If OnScreen is false then it will become true and show the Frame
				OnScreen = true
				local NewBlur = Instance.new("BlurEffect") -- Creates new blur
				NewBlur.Name = "FrameBlur" -- Renames it to FrameBlur
				NewBlur.Parent = game:GetService("Lighting") -- Parents it to Lighting
				
				Frame.Visible = true
			elseif OnScreen then
				OnScreen = false
				game:GetService("Lighting"):FindFirstChild("FrameBlur"):Destroy()
				Frame.Visible = false
			end
		end
	end
end)

1 comment

0

Thx

This discussion is preserved as it was. New answers, comments, and votes are closed.