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

Making a GUI appear when you aren't typing in the chat?

Hello guys, I have simple script that when the "F" button is pressed a GUI appears. However, my only problem with is this is that when in-game and using a word that contains the letter it appears. How would I efficiently make it so that it only appears when you aren't typing in the chat?

Here is the script for reference.

local Frame = script.Parent

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.F then
		Frame.Visible = true
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

1 answer

✓ Accepted answer

The second parameter of the InputBegan event is gameProcessedEvent, as defined in your function. It will be true if you are typing on another gui, etc. Acknowledging this, we can use an if statement to check if the gameProcessedEvent is not true, then do the stuff that you wanted:

local Frame = script.Parent

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.F and not gameProcessedEvent then
        Frame.Visible = true
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

1 comment

0

Thank you very much, i usually write scripts and have a break and completely forget about things..

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