local t=nil if IsTouchDevice then createTouchGuiContainer()t=function()local t=nil if not IsUserChoice then if DevMovementMode==Enum.DevTouchMovementMode.Thumbstick then t=ControlModules.Thumbstick isJumpEnabled=true elseif DevMovementMode==Enum.DevTouchMovementMode.Thumbpad then t=ControlModules.Thumbpad isJumpEnabled=true elseif DevMovementMode==Enum.DevTouchMovementMode.DPad then t=ControlModules.DPad elseif DevMovementMode==Enum.DevTouchMovementMode.ClickToMove then t=nil elseif DevMovementMode==Enum.DevTouchMovementMode.Scriptable then t=nil end else if UserMovementMode==Enum.TouchMovementMode.Default or UserMovementMode==Enum.TouchMovementMode.Thumbstick then t=ControlModules.Thumbstick isJumpEnabled=true elseif UserMovementMode==Enum.TouchMovementMode.Thumbpad then t=ControlModules.Thumbpad isJumpEnabled=true elseif UserMovementMode==Enum.TouchMovementMode.DPad then t=ControlModules.DPad elseif UserMovementMode==Enum.TouchMovementMode.ClickToMove then t=nil end end setClickToMove()if t~=CurrentControlModule then if CurrentControlModule then CurrentControlModule:Disable()end setJumpModule(isJumpEnabled)CurrentControlModule=t if CurrentControlModule and not IsModalEnabled then CurrentControlModule:Enable()if isJumpEnabled then TouchJumpModule:Enable()end end end end elseif UserInputService.KeyboardEnabled then t=function()local t=nil if not IsUserChoice then if DevMovementMode==Enum.DevComputerMovementMode.KeyboardMouse then t=ControlModules.Keyboard elseif DevMovementMode==Enum.DevComputerMovementMode.ClickToMove then t=ControlModules.Keyboard end else if UserMovementMode==Enum.ComputerMovementMode.KeyboardMouse or UserMovementMode==Enum.ComputerMovementMode.Default then t=ControlModules.Keyboard elseif UserMovementMode==Enum.ComputerMovementMode.ClickToMove then t=ControlModules.Keyboard end end if t~=CurrentControlModule then if CurrentControlModule then CurrentControlModule:Disable()end CurrentControlModule=t if CurrentControlModule then CurrentControlModule:Enable()end end end elseif UserInputService.GamepadEnabled then t=function() end end
--
local onControlsChanged = nil
if IsTouchDevice then
	createTouchGuiContainer()
	onControlsChanged = function()
		local newModuleToEnable = nil
		if not IsUserChoice then
			if DevMovementMode == Enum.DevTouchMovementMode.Thumbstick then
				newModuleToEnable = ControlModules.Thumbstick
				isJumpEnabled = true
			elseif DevMovementMode == Enum.DevTouchMovementMode.Thumbpad then
				newModuleToEnable = ControlModules.Thumbpad
				isJumpEnabled = true
			elseif DevMovementMode == Enum.DevTouchMovementMode.DPad then
				newModuleToEnable = ControlModules.DPad
			elseif DevMovementMode == Enum.DevTouchMovementMode.ClickToMove then
				-- Managed by CameraScript
				newModuleToEnable = nil
			elseif DevMovementMode == Enum.DevTouchMovementMode.Scriptable then
				newModuleToEnable = nil
			end
		else
			if UserMovementMode == Enum.TouchMovementMode.Default or UserMovementMode == Enum.TouchMovementMode.Thumbstick then
				newModuleToEnable = ControlModules.Thumbstick
				isJumpEnabled = true
			elseif UserMovementMode == Enum.TouchMovementMode.Thumbpad then
				newModuleToEnable = ControlModules.Thumbpad
				isJumpEnabled = true
			elseif UserMovementMode == Enum.TouchMovementMode.DPad then
				newModuleToEnable = ControlModules.DPad
			elseif UserMovementMode == Enum.TouchMovementMode.ClickToMove then
				-- Managed by CameraScript
				newModuleToEnable = nil
			end
		end
		setClickToMove()
		if newModuleToEnable ~= CurrentControlModule then
			if CurrentControlModule then
				CurrentControlModule:Disable()
			end
			setJumpModule(isJumpEnabled)
			CurrentControlModule = newModuleToEnable
			if CurrentControlModule and not IsModalEnabled then
				CurrentControlModule:Enable()
				if isJumpEnabled then TouchJumpModule:Enable() end
			end
		end
	end
elseif UserInputService.KeyboardEnabled then
	onControlsChanged = function()
		-- NOTE: Click to move still uses keyboard. Leaving cases in case this ever changes.
		local newModuleToEnable = nil
		if not IsUserChoice then
			if DevMovementMode == Enum.DevComputerMovementMode.KeyboardMouse then
				newModuleToEnable = ControlModules.Keyboard
			elseif DevMovementMode == Enum.DevComputerMovementMode.ClickToMove then
				-- Managed by CameraScript
				newModuleToEnable = ControlModules.Keyboard
			end 
		else
			if UserMovementMode == Enum.ComputerMovementMode.KeyboardMouse or UserMovementMode == Enum.ComputerMovementMode.Default then
				newModuleToEnable = ControlModules.Keyboard
			elseif UserMovementMode == Enum.ComputerMovementMode.ClickToMove then
				-- Managed by CameraScript
				newModuleToEnable = ControlModules.Keyboard
			end
		end
		if newModuleToEnable ~= CurrentControlModule then
			if CurrentControlModule then
				CurrentControlModule:Disable()
			end
			CurrentControlModule = newModuleToEnable
			if CurrentControlModule then
				CurrentControlModule:Enable()
			end
		end
	end
elseif UserInputService.GamepadEnabled then
	onControlsChanged = function()
		-- nil for now, probably needs some stuff later
	end
end
