I have a script that when you press TAB it opens up a gui, but I don’t know how to make it so that if you let go of TAB the gui closes. I am not too familiar with UIS(UserInputService) so if anybody could help me it would be appreciated.
Here is the script that I placed in StarterPack
UIS.InputBegan:Connect(function(Input, isTyping)
if isTyping then return end
if UIS:IsKeyDown(Enum.KeyCode.Tab) then
plrGUI.Enabled = true
end
end)
I think you can use InputEnded in conjuction with your InputBegan
UIS.InputEnded:Connect(function(Input, isTyping)
if isTyping then return end
if UIS:IsKeyDown(Enum.KeyCode.Tab) then
plrGUI.Enabled = false
end
end)
Also wait why exactly are you using if UIS:IsKeyDown(Enum.KeyCode.Tab) then to detect key presses in InputBegan? Wouldn’t if Input.KeyCode == Enum.KeyCode.Tab then also work for your needs?
Thank you! It works now but I changed up the code a bit, and made it to Input.KeyCode = Enum.KeyCode.Tab and it works better now. I thought using InputBegan would work better but I guess not.
Anytime! If you have anymore issues don’t be afraid to make another post!
And also, InputBegan only listens for inputs that have began as the name implies, so if you let go of Tab,it wont listen to that. Your code would only really work if you let go of tab and press another key, which is probably unintended behaviour. So I’m glad to have taught you a better method to do something as well!