I am working on a game based on sports, with some sports which are practiced by two teams, and I need a screen click/tap event. Since I made a custom chat GUI I need an event which detects if a player clicks/taps the screen on the screen and without clicking/taping any GUIs.
✓ ANSWER ACCEPTED
How can I detect if a player clicks/taps the screen without clicking/tapping any GUI?
1 answer
✓ Accepted answer
In a local script inside of StarterPlayerScripts, I put:
local userinputservice = game:GetService("UserInputService")
userinputservice.InputBegan:Connect(function(input, gameProcessedEvent)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then -- When a player clicks the screen
if gameProcessedEvent == true then -- If the player pressed a button.
else
-- Put your code here
end
end
end)
This will run your code where it says "Put your code here" if the player presses a screen. It won't run when a button is pressed but will work if you press a TextLabel.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
only use if not gameProcessedEvent then
Thanks!
yHasteeD this works though