if IsTouchDevice then LocalPlayer.CharacterAdded:connect(function(R)createTouchGuiContainer()if CurrentControlModule then CurrentControlModule:Disable()CurrentControlModule=nil end onControlsChanged()end)UserInputService.Changed:connect(function(R)if R=="\077\111\100\097\108\069\110\097\098\108\101\100"then IsModalEnabled=UserInputService.ModalEnabled setJumpModule(not UserInputService.ModalEnabled)if UserInputService.ModalEnabled then if CurrentControlModule then CurrentControlModule:Disable()end else if CurrentControlModule then CurrentControlModule:Enable()end end end end)BindableEvent_OnFailStateChanged.Event:connect(function(R)if ClickToMoveTouchControls then if R then ClickToMoveTouchControls:Enable()else ClickToMoveTouchControls:Disable()end if ClickToMoveTouchControls==ControlModules.Thumbpad or ClickToMoveTouchControls==ControlModules.Thumbstick or ClickToMoveTouchControls==ControlModules.Default then if R then TouchJumpModule:Enable()else TouchJumpModule:Disable()end end end end)end MasterControl:Init()onControlsChanged()
--[[ Touch Events ]]
--
if IsTouchDevice then
	-- On touch devices we need to recreate the guis on character load.
	LocalPlayer.CharacterAdded:connect(function(character)
		createTouchGuiContainer()
		if CurrentControlModule then
			CurrentControlModule:Disable()
			CurrentControlModule = nil
		end
		onControlsChanged()
	end)

	UserInputService.Changed:connect(function(property)
		if property == "ModalEnabled" then
			IsModalEnabled = UserInputService.ModalEnabled
			setJumpModule(not UserInputService.ModalEnabled)
			if UserInputService.ModalEnabled then
				if CurrentControlModule then
					CurrentControlModule:Disable()
				end
			else
				if CurrentControlModule then
					CurrentControlModule:Enable()
				end
			end
		end
	end)

	BindableEvent_OnFailStateChanged.Event:connect(function(isOn)
		if ClickToMoveTouchControls then
			if isOn then
				ClickToMoveTouchControls:Enable()
			else
				ClickToMoveTouchControls:Disable()
			end
			if
				ClickToMoveTouchControls == ControlModules.Thumbpad
				or ClickToMoveTouchControls == ControlModules.Thumbstick
				or ClickToMoveTouchControls == ControlModules.Default
			then
				--
				if isOn then
					TouchJumpModule:Enable()
				else
					TouchJumpModule:Disable()
				end
			end
		end
	end)
end

MasterControl:Init()
onControlsChanged()
