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

GUI's come up while chatting, unsure how to disable?

Alright so I have some keys set up so when you press them it brings up the GUI. Well problem is they happen to come up while chatting as well. So if I want to type "Hey" it'll bring up my Help GUI because I set H to do that, here is the code, is there a way to get rid of this?

local player = script.Parent.Parent
local guis = game.ReplicatedStorage.PopUps

function onKeyPress(inputObject, gameProccessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.H then
		local help = guis.Help:Clone()
		help.Parent = player.PlayerGui
		player.PlayerGui.PlayerAudio.Pullup:Play()
		end
	end
end

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

function onKeyPress(inputObject, gameProccessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Q then
		local options = guis.Options:Clone()
		options.Parent = player.PlayerGui
		player.PlayerGui.PlayerAudio.Pullup:Play()
	end
end

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


1 answer

✓ Accepted answer

There's a second argument of InputBegan, gameProceessedEvent, it's true when you're chatting and false when you aren't. Just put an if statement before you check if it was a keypressed to avoid it firing when chatting

function onKeyPress(inputObject, gameProccessedEvent)
	if not gameProccessedEvent then
		print'key was pressed but not while chatting c:'
	end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

1 comment

0

Thanks! :D

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