Requiring the PlayerModule duplicates the TouchGui on mobile

For starters I’m aware this might not be the appropriate category for this topic, but Roblox isn’t helping by locking bug reports or where ever this topic fits best.

Now, requiring the PlayerModule duplicates the TouchGui on mobile devices (or at least when running the emulator) once and only once, literally spent 30 minutes debugging my code, just to come to the conclusion it’s another Roblox issue lol, I’m currently reading the PlayerModule to find the issue.

1 Like

Yeah no sane person is reading all of those modules, here’s a patch job for solving the issue.

local DesktopEnabled, ConsoleEnabled, TouchEnabled = (function()
	local DesktopEnabled, ConsoleEnabled = (UserInputService.KeyboardEnabled and UserInputService.MouseEnabled), ((UserInputService.GamepadEnabled and GuiService:IsTenFootInterface()) and (not UserInputService.TouchEnabled));
	local TouchEnabled = ((not DesktopEnabled and not ConsoleEnabled) and UserInputService.TouchEnabled);
	
	if (TouchEnabled) then
		PlayerGui:WaitForChild('TouchGui'):Destroy();
	end;
	
	return DesktopEnabled, ConsoleEnabled, TouchEnabled;
end)();

local PlayerControls = require(PlayerScripts:WaitForChild('PlayerModule')):GetControls();
local TouchGui = LocalPlayer:WaitForChild('TouchGui');

No guarantee that the issue might arise again once the player respawns, but whatever lol.

Edit: Yeah I was correct, we have to check for a duplication added because it duplicates randomly once required again…

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