--print(Hit, Hit.Name)

			if Hit.Name == "Terrain" or Hit.CanCollide == false then -- In front is Water or a steep hill made of Terrain.
				Hit = nil  -- swim or climb, or Ray hit a Non-colliding Part; and don't check for floor. This will not do, as we do not get a Hit when under-water, so we will check for floor. We must check Swimming event.
			else -- Jump?
				Hit = DrawRay(originPrime + Vector3.new(0,4.8,0), pointPrime)
				if Hit == nil then  -- (Does NOT check CanCollide of Part blocking Jump)
					hum.Jump = true  --  we do NOT check for "Floor", if jumping, but it might be a good idea.
				end -- Room to jump?
			end --Terrain? Water?
		end -- Ladder?

	else	-- path is clear. Check for cliff... or OK to drop

	local Level = torsoPos.y 
		if target then
			Level = target.Position.y  -- get Target's current position.
		else  -- Target is dead. Abandon all logic...
			Logic = 0		 -- but still check for floor
		end

		if torsoPos.y - 2 < Level then  -- if Player is not well below us...
 
			Hit = DrawRay(torsoPos + point * .8 + Vector3.new(0,1,0), Vector3.new(0,-7,0)) -- check for floor 85% of dir ahead
			if Hit == nil then -- There is no floor
				Hit = true  -- Force a hit; we may not be able to get back up here.

			else
				Hit = nil  -- Force a false to hit, 'cause everything is OK. (Does NOT check CanCollide of Floor!)
			end -- cliff check
		end -- Player Hieght
	end  -- path ok?
return Hit
end -- FireRayToward


function FireAtPlayer()
	origin = CFrame.new(torsoPos, Vector3.new(targpos.x, torsoPos.y, targpos.z)) -- This contains Origin & Direction
local hit =	FireRayToward()
return hit
end

function FireRayAhead()
	origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdir, 0, Zdir))
local hit =	FireRayToward()
	targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
return hit
end

function FireRay() -- Fire Ahead and diagonaly
	origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdag, 0, Zdag))
local hit = FireRayToward()
	if hit then
		origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdir, 0, Zdir))
		hit = FireRayToward()
		if not hit then
			targpos = torsoPos + Vector3.new(Xdir,0,Zdir)
		end
	else
			targpos = torsoPos + Vector3.new(Xdag,0,Zdag)
	end
return hit
end -- Fire Ray

function FireDag()
origin = CFrame.new(torsoPos, torsoPos + Vector3.new(Xdag, 0, Zdag))
local	hit = FireRayToward()
return hit
end -- Fire Diagonaly


function	TurnRight()

	if Xdir == 0 then
		Xdir = -Zdir
      Zdir = 0
	else
      Zdir = Xdir
      Xdir = 0
	end
	if Xdag == Zdag then Xdag = -Xdag else	Zdag = -Zdag end

end -- Left

function	TurnLeft()
	if Xdir == 0 then
		Xdir = Zdir
      Zdir = 0
	else
      Zdir = -Xdir
      Xdir = 0
	end

	if Xdag == Zdag then Zdag = -Zdag else	Xdag = -Xdag end
	
end -- Left


function GetDir()
				Xdir = (targpos.x - torsoPos.x) -- Which way are we going?
				Zdir = (targpos.z - torsoPos.z) 
