My code does not detect if a player is playing with touch

Well, I’m trying to detect if a player is playing on keyboard and mouse or if they are playing with controller or touch. Yes it detects me if you are playing with keyboard, mouse or gamepad, but not with touch


local Hardware_pc = {
	Enum.UserInputType.Keyboard,
	Enum.UserInputType.MouseMovement,
	Enum.UserInputType.MouseWheel
}
local Hardware_other = {
	Enum.UserInputType.Gamepad1,
	Enum.UserInputType.Gamepad2,
	Enum.UserInputType.Gamepad3,
	Enum.UserInputType.Gamepad4,
	Enum.UserInputType.Gamepad5,
	Enum.UserInputType.Gamepad6,
	Enum.UserInputType.Gamepad7,
	Enum.UserInputType.Gamepad8,
	Enum.UserInputType.Touch,
}

USER_INPUT_SERVICE.InputChanged:Connect(function(Input, gameProcessed)
	if(gameProcessed and PLAYER_GUI:FindFirstChild("ScreenLoad"))then return end
	if (table.find(Hardware_pc, Input.UserInputType))then
		if(singleton.ChangeController == true and singleton.IsEnabled == false and singleton.OriginalPosCam == nil)then
			singleton:Enable();
		end
		singleton.ChangeController = false;
	elseif(table.find(Hardware_other, Input.UserInputType))then
		if(singleton.ChangeController == false and singleton.IsEnabled == true and singleton.OriginalPosCam == nil)then
			singleton:Disable();
		end
		singleton.ChangeController = true
	end
end)

What do you mean by touch? are you referring to mobile or something?

Yes, I’m trying to detect if a player is playing with keyboard and mouse, gamepad or mobile touch

1 Like

you can go check this post : How to detect if Player is using a Phone? - #4 by buildthomas

1 Like