UserInputService input began help

What do I want to achieve?
I would like to close a gui with a player pressing two keys at once

What’s the problem?
I have 2 keys that need to be pressed to call the function, it would work with the first option inside the if statement immediately

(Sorry if I do not word this post correctly, I have trouble with grammar)

Here’s my code if you are curious:

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input)
     if input.Keycode == Enum.KeyCode.LeftControl and Enum.KeyCode.Z then
          script.Parent.Visible = false
     end
end)

Thanks for the help

1 Like

Use IsKeyDown

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
	if uis:IsKeyDown(Enum.KeyCode.LeftControl) and uis:IsKeyDown(Enum.KeyCode.Z) then
		script.Parent.Visible = false
	end
end)
1 Like

.Thanks for the help, SOTR654!