Disable mobile controls?

I was wondering if there was a way to disable mobile controls (move and jump) and re-able them later? I set the players jump and walkspeed to 0 and it seemed to remove the jump button but the walk button is still in the way.

The reason I want to disable it is because they get in the way of my menu screen and buttons on the menu screen. So I wanna have the buttons disable while they’re in the menu screen and re-enable them when they leave the screen

13 Likes

UserInputService.ModalEnabled = true

5 Likes

It doesn’t work :confused: I have it set to true, and even put a print, that prints true, but the walk button is still there

5 Likes

When are you setting it?

2 Likes

You have have to wait for the client to load the CoreScripts first before you can set the Modal State. Try waiting around 1/30 of a second before firing that command.

4 Likes

Set them to false beforehand?

1 Like

So it actually turns out that the documentation is incorrect. UserInputService.ModalEnabled = false will hide the Mobile interface, and UserInputService.ModalEnabled = true will show them.

13 Likes

Excuse me for the bump but it seems UserInputService.ModalEnabled doesn’t work. And even if it did work it only hides the Mobile controls, not disable them.

2 Likes

In StarterGui do:
image
And what will disabled the mobile controls.

4 Likes

Its a little out landish but it works

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	if UserInputService.TouchEnabled then
		if Player.PlayerGui.TouchGui.TouchControlFrame:FindFirstChild("DynamicThumbstickFrame") then
			Player.PlayerGui.TouchGui.TouchControlFrame.DynamicThumbstickFrame:Destroy()
		end
		
		Character.Humanoid.WalkSpeed = 0
		Character.Humanoid.JumpPower = 0
	end
end)

This should disable all movement for a player in mobile

3 Likes

Info here on the upcoming fix (link updated):

5 Likes