How to make UserInputService not detect mobile joystick touches

hello everyone,

I’m currently making a custom tool activation script that relies on checking clicks for the player. It works well for PC users as they don’t have much roblox built-in gui. However, mobile users have the jump button and the joystick, the jump button doesn’t get detected by my script but whenever I use the joystick the script would fire.

Is there a way to make UserInputService not detect the joystick?

here is my simple code btw:

local Player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local ToolRemoteEvent = game:GetService("ReplicatedStorage").RemoteEvents:WaitForChild("ToolsActionRemoteEvent")

local function ToolActivationFunction(Input,active)
	
	if (Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch) and not active then
	print(1)	
	end
	
end

UserInputService.InputBegan:Connect(ToolActivationFunction)

Thank you.

Pretty sure you cant really detect the joystick with UIS, unless you open the TouchControls GUI and do some wacky code there, but there is an alternative way.

With InputBegan, you can check what direction the player is trying to go, which can simulate detecting what direction the player is moving their joystick

There are Enums for this, inside of Enum.PlayerActions. Theres CharacterMoveFoward, CharacterMoveBackward, CharacterMoveLeft, CharacterMoveRight, and, as the name suggests, shows what direction the player is moving toward. I believe you can hook this up easily with UIS.InputBegan, because I cant see why you wouldnt be able to.

edit: i completely misread your entire post im sorry about that :skull:

For your actual question, you could try something similar by checking if they are moving with a touchBegan, but I aint sure if itll work, and im not that familiar with mobile controls to be able to help you with this, sorry :frowning:

1 Like

it seems to be an issue with dynamic Thumbstick not working well with UserInputService. Classic Thumbstick seems to be working better, thank you anyways

for anyone seeing this and still want to use dynamic thumbstick.

dynamic thumbstick will only fire the UserInputService if you have used UserInputService.InputBegan. Instead use UserInputService.InputEnded

1 Like

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