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

Input keycode triggers when I chat, I just want it when they hit the key. Can anyone help?

Below is my code, I don't want this to trigger when the player is chatting but I do want it to when they hit the key though.

function onKeyPressed(inputObject, gameProcessEvent)
	if inputObject.KeyCode == Enum.KeyCode.E then
		print("E")

1 comment

0

Use the 'GameProcessedEven't boolean...................

2 answers

✓ Accepted answer

Hey there, there is a preatty easy solution for that! You can use the context action service in roblox, so it wont trigger when you write in chat.

Here is the link to ContextActionService: https://developer.roblox.com/en-us/api-reference/class/ContextActionService.

I hope I could help you out. If you need any help implementing it into your systeme, make sure to contact me, so I can help you out. Have a nice day, esepek.

2 comments

0

You have to be kidding me. You do realize that there is a parameter supplied to the 'InputBegan' Callback that can debounce this... You have no need to shift to entirely new Service.

0

Well I think CAS is the best solution in this case. Not only can you solve the current problem but its much easyer to define when certain inputs should have an effect or not. And YES you could check if another script has already processed the input , but why wouldnt you just go with CAS in the first place? I mean what if he wants to add Mobile buttons?? I think CAS is the better solution here!

Hello @NortonHDD, I realized that although gameProessedEvent is a parameter of your function, you don't actually check if the event is game processed or not.

Try this:

local function onKeyPressed(inputObject, gameProcessEvent)
	if not (gameProcessEvent) then
		if inputObject.KeyCode == Enum.KeyCode.E then
			print("E")
		end
	end
end

Hope this helps :D

1 comment

0

If the InputBegan Event was processed by the game's core-scripts, to be exact in its definition.

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