local function R()local R={}R.TorsoLookPoint=nil function R.SetTorsoLookPoint(h,j)local q=findPlayerHumanoid(Player)if q then q.AutoRotate=false end R.TorsoLookPoint=j h:UpdateTorso()delay(2,function()if R.TorsoLookPoint==j then R.TorsoLookPoint=nil if q then q.AutoRotate=true end end end)end function R.UpdateTorso(h,j)if R.TorsoLookPoint then j=R.TorsoLookPoint else return end local q=findPlayerHumanoid(Player)local y=q and q.Torso if y then local R=(j-y.CFrame.p).unit local h=(Vector3_new(R.X,0,R.Z)).unit y.CFrame=CFrame.new(y.CFrame.p,y.CFrame.p+h)end end return R end local j=R()
--------------------------CHARACTER CONTROL-------------------------------
local function CreateController()
	local this = {}

	this.TorsoLookPoint = nil

	function this:SetTorsoLookPoint(point)
		local humanoid = findPlayerHumanoid(Player)
		if humanoid then
			humanoid.AutoRotate = false
		end
		this.TorsoLookPoint = point
		self:UpdateTorso()
		delay(2, function()
			-- this isnt technically correct for detecting if this is the last issue to the setTorso function
			if this.TorsoLookPoint == point then
				this.TorsoLookPoint = nil
				if humanoid then
					humanoid.AutoRotate = true
				end
			end
		end)
	end

	function this:UpdateTorso(point)
		if this.TorsoLookPoint then
			point = this.TorsoLookPoint
		else
			return
		end

		local humanoid = findPlayerHumanoid(Player)
		local torso = humanoid and humanoid.Torso
		if torso then
			local lookVec = (point - torso.CFrame.p).unit
			local squashedLookVec = Vector3_new(lookVec.X, 0, lookVec.Z).unit
			torso.CFrame = CFrame.new(torso.CFrame.p, torso.CFrame.p + squashedLookVec)
		end
	end

	return this
end

local CharacterControl = CreateController()
