function humanoidControl.setMode(t,C,J)t._mode=C if C==Enum.HumanoidControlType.Locked then t._lockedMoveVector=J end end function humanoidControl.getWorldMoveDirection(J,C)local t=C or J._mode if t==Enum.HumanoidControlType.Default then return J.humanoid.MoveDirection elseif t==Enum.HumanoidControlType.Locked then return J._lockedMoveVector elseif t==Enum.HumanoidControlType.Forced or t==Enum.HumanoidControlType.ForcedRespectCamera then local C=J.humanoid.MoveDirection local O=C:Dot(C)if t==Enum.HumanoidControlType.ForcedRespectCamera and O==0 then C=(CAMERA.CFrame.lookVector*Vector3.new(1,0,1)).unit O=1 end local m=J.hrp.CFrame.lookVector local h=math.atan2(-m.z,m.x)local g=O>0 and math.atan2(-C.z,C.x)or h J._forcedMoveVector=CFrame.fromEulerAnglesYXZ(0,g,0)*Vector3.new(1,0,0)return J._forcedMoveVector end end
--

function humanoidControl:setMode(newMode, moveVec)
	self._mode = newMode
	if newMode == Enum.HumanoidControlType.Locked then
		self._lockedMoveVector = moveVec
	end
end

function humanoidControl:getWorldMoveDirection(enum)
	local mode = enum or self._mode

	if mode == Enum.HumanoidControlType.Default then
		return self.humanoid.MoveDirection
	elseif mode == Enum.HumanoidControlType.Locked then
		return self._lockedMoveVector
	elseif mode == Enum.HumanoidControlType.Forced or mode == Enum.HumanoidControlType.ForcedRespectCamera then
		local worldMove = self.humanoid.MoveDirection
		local worldMoveSq = worldMove:Dot(worldMove)

		if mode == Enum.HumanoidControlType.ForcedRespectCamera and worldMoveSq == 0 then
			worldMove = (CAMERA.CFrame.lookVector * Vector3.new(1, 0, 1)).unit
			worldMoveSq = 1
		end

		local look = self.hrp.CFrame.lookVector
		local realTheta = math.atan2(-look.z, look.x)
		local worldTheta = worldMoveSq > 0 and math.atan2(-worldMove.z, worldMove.x) or realTheta

		self._forcedMoveVector = CFrame.fromEulerAnglesYXZ(0, worldTheta, 0) * Vector3.new(1, 0, 0)

		return self._forcedMoveVector
	end
end
