So I have this script that when a keybind is pressed, it should open/close a gui, and it works, but it is delayed with its closing, any help? here is the script
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(k)
k = k:lower()
if k == "r" then
script.Parent.MENU.Visible = true
else
if script.Parent.MENU.Visible == true then
script.Parent.MENU.Visible = false
end
end
end)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(k)
k = k:lower()
if k == "r" then
script.Parent.MENU.Visible = true
elseif script.Parent.MENU.Visible == true then
script.Parent.MENU.Visible = false
end
end)
local UserInputService = game:GetService("UserInputService")
local Menu = script.Parent.MENU
UserInputService.InputBegan:Connect(function(Input, Process)
if Input.KeyCode == Enum.KeyCode.R and not Process then
if Menu.Visible == false then -- if it's not visible then make it visible
Menu.Visible = true
else -- if it's visible then make it not visible
Menu.Visible = false
end
end
end)