I'm trying to make some code to open a GUI when I press a certain key. It's going well but something went wrong. My code:
local UserInputService = game:GetService("UserInputService") while game.Players.LocalPlayer ~= nil do wait(0.08) end local Player = game:GetService("Players").LocalPlayer wait(1) local PlayerGui = Player:WaitForChild("PlayerGui") function enable() script.Parent.Enable.Value = 1 while game.Lighting.Blur.Size < 10 do game.Lighting.Blur.Size = game.Lighting.Blur.Size + 2 wait(0.1) end end function disable() script.Parent.Enabled = 0 while game.Lighting.Blur.Size > 0 do game.Lighting.Blur.Size = game.Lighting.Blur.Size - 2 wait(0.1) end end UserInputService.InputBegan:Connect(function(Input, GameProcessed) if (Input.KeyCode == Enum.KeyCode.P) then for _,v in pairs(PlayerGui:GetChildren()) do if (v:IsA("ScreenGui")) then if script.Parent.Enable.Value == 0 then enable() v.Enabled = true end if script.Parent.Enable.Value == 1 then disable() v.Enabled = false end else if script.Parent.Enable.Value == 0 then enable() v.Visible = true end if script.Parent.Enable.Value == 1 then disable() v.Visible = false end end end end end)