UserInputService works on GUI?

Hey, I am making a game where you throw a ball at people that involves you to click your screen using UserInputService. Here is an example below

local UserInputServices = game:GetService("UserInputService")

UserInputServices.InputBegan:Connect(function(input)
	if UserInputServices.MouseEnabled then
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
---Code here

The thing is it works fine, but when I click on a GUI it keeps going. Every time you click no matter of your in a GUI it will still go. This gets annoying after a while and I cant fix it. I also have another instance when this happens. When you press an E key you get an ability. Example below.

UserInputService.InputBegan:Connect(function(input)
	if not UserInputService.TouchEnabled then
		if input.KeyCode == Enum.KeyCode.E then

When your typing something in chat, these ability does off if you type in E in the chat. This can get really frustrating if your trying to chat with your friend in-game as some abilities have a lot of vfx.
Is there a value on GUIs or the TextChatService? I don’t know how to fix it and I don’t see it anywhere else.

Thanks (I do check often in the forum so I will respond quick)

use the gameproccesedevent UserInputService | Documentation - Roblox Creator Hub

UserInputService.InputBegan:Connect(function(input, gp)
	if not UserInputService.TouchEnabled then
		if input.KeyCode == Enum.KeyCode.E and not gp then
1 Like

Hi I cant find game proccesed event in the userinputservice forum you sent me

Use the code that I provided if it dosen’t work reply to me.

Alright it works! Now we got to finish the throwing script, since that one is click to throw. Im guessing We use the same concept (also tysm ill give you solution soon)

Quick refresher if you need it

local UserInputServices = game:GetService("UserInputService")

UserInputServices.InputBegan:Connect(function(input)
	if UserInputServices.MouseEnabled then
		if input.UserInputType == Enum.UserInputType.MouseButton1 then

Thanks! And yes everytime when you use inputservice if you want the same effect then use gameProccessed event (gp)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.