local function o()local o={}o.TorsoLookPoint=nil function o.SetTorsoLookPoint(j,v)local S=findPlayerHumanoid(Player)if S then S.AutoRotate=false end o.TorsoLookPoint=v j:UpdateTorso()delay(2,function()if o.TorsoLookPoint==v then o.TorsoLookPoint=nil if S then S.AutoRotate=true end end end)end function o.UpdateTorso(j,v)if o.TorsoLookPoint then v=o.TorsoLookPoint else return end local S=findPlayerHumanoid(Player)local V=S and S.Torso if V then local o=(v-V.CFrame.p).unit local j=(Vector3.new(o.X,0,o.Z)).unit V.CFrame=CFrame.new(V.CFrame.p,V.CFrame.p+j)end end return o end local v=o()
--------------------------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()
