Unable to properly enable mobile default UI after previously disabling it

You can see the issue on the mobile playtesting video. Note that this issue is only on Touch Enabled devices, there is no issues on computers.

You can write your topic however you want, but you need to answer these questions:

I want the player to be able to use the dynamic joystick and jump button normally like seen before it was disabled

At the moment, when the script calls the local function enableControls(), the moment the touch button is tapped, it stays tapped almost like a player is holding down the jump button. Additionally, no matter how many times I try to move the character with the dynamic joystick, no movement is shown.

I have tried looking for solutions on the forum, but the only issues I found were related to only disabling the mobile UI but not enabling and disabling back in forth.

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local PlayerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()

local isTouchDevice = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled

local function disableControls()
	if Controls and isTouchDevice then
		Controls:Disable()
	end
end

local function enableControls()
	
	if Controls and isTouchDevice then
		Controls:Enable()
	end
end

I would appreciate any help! :slight_smile: This is an important system I’m making and this issue has been delaying my progress.

Im guessing its because the enable function is coded to start the control input instead of allowing it.
To solve this, you could use boolean values to set when the controls are enabled.

Can i see the module scripts for the control enabling?

Here are the funcitons I am calling



function ControlModule:UpdateActiveControlModuleEnabled()
	-- helpers for disable/enable
	local disable = function()
		self.activeController:Enable(false)
		if self.touchJumpController then 
			self.touchJumpController:Enable(false)
		end

		if self.moveFunction then
			self.moveFunction(Players.LocalPlayer, Vector3.new(0,0,0), true)
		end
	end

	local enable = function()
		if
			self.touchControlFrame
			and (
				self.activeControlModule == ClickToMove
				or self.activeControlModule == TouchThumbstick
				or self.activeControlModule == DynamicThumbstick
			)
		then
			if not self.controllers[TouchJump] then
				self.controllers[TouchJump] = TouchJump.new()
			end
			self.touchJumpController = self.controllers[TouchJump]
			self.touchJumpController:Enable(true, self.touchControlFrame)
		else
			if self.touchJumpController then
				self.touchJumpController:Enable(false)
			end
		end

		if self.activeControlModule == ClickToMove then
			-- For ClickToMove, when it is the player's choice, we also enable the full keyboard controls.
			-- When the developer is forcing click to move, the most keyboard controls (WASD) are not available, only jump.
			self.activeController:Enable(
				true,
				Players.LocalPlayer.DevComputerMovementMode == Enum.DevComputerMovementMode.UserChoice,
				self.touchJumpController
			)
		elseif self.touchControlFrame then
			self.activeController:Enable(true, self.touchControlFrame)
		else
			self.activeController:Enable(true)
		end
	end

	-- there is no active controller
	if not self.activeController then
		return
	end

	-- developer called ControlModule:Disable(), don't turn back on
	if not self.controlsEnabled then
		disable()
		return
	end

	-- GuiService.TouchControlsEnabled == false and the active controller is a touch controller,
	-- disable controls
	if not GuiService.TouchControlsEnabled and UserInputService.TouchEnabled and
		(self.activeControlModule == ClickToMove or self.activeControlModule == TouchThumbstick or
			self.activeControlModule == DynamicThumbstick) then
		disable()
		return
	end

	-- no settings prevent enabling controls
	enable()
end

function ControlModule:Enable(enable: boolean?)
	if enable == nil then
		enable = true
	end
	if self.controlsEnabled == enable then return end
	self.controlsEnabled = enable

	if not self.activeController then
		return
	end

	self:UpdateActiveControlModuleEnabled()
end

-- For those who prefer distinct functions
function ControlModule:Disable()
	self:Enable(false)
end

I was guessing these two functions would be the two to enable and disable this. I’m not familiar with the control module, this is my first time ever using it :shock:

I hope this helps :slight_smile:

I

Respectfully, This is out of my skill level. I dont think I can help

1 Like

No worries, I don’t get it either XD
Thanks for trying though!

1 Like