function heardetect(f)local N=nil local o=Instance.new("\080\097\114\116",script.debris)o.Anchored=true o.CanCollide=false o.Color=Color3.fromRGB(255,150,150)o.Material=Enum.Material.Neon o.Name="\076\097\115\101\114\066\101\097\109"o.Transparency=1 local r=script.Parent.Head local y=Ray.new(r.CFrame.p,(CFrame.new(r.CFrame.Position,f.Position)).LookVector*distance)local B,S=game.Workspace:FindPartOnRayWithIgnoreList(y,{r;o;script.debris},false,true)local E=(r.CFrame.p-S).Magnitude if visibleray==true then o.Size=Vector3.new(.1,.1,E)o.CFrame=CFrame.new(r.CFrame.Position,f.Position)*CFrame.new(0,0,-E/2)o.Transparency=0 else o:Destroy()end if B~=nil then if game.Players:GetPlayerFromCharacter(B.Parent)or game.Players:GetPlayerFromCharacter(B.Parent.Parent)then GoTo(f.Position)if(f.Position-script.Parent.Head.Position).Magnitude<damagerange then attack()end o.BrickColor=BrickColor.new("\066\114\105\103\104\116 \098\108\117\101")else o.BrickColor=BrickColor.new("\082\101\097\108\108\121 \114\101\100")end else o.BrickColor=BrickColor.new("\087\104\105\116\101")end wait()end

function heardetect(part)
	local target = nil
	local Beam = Instance.new("Part", script.debris)
	Beam.Anchored = true
	Beam.CanCollide = false
	Beam.Color = Color3.fromRGB(255, 150, 150)
	Beam.Material = Enum.Material.Neon
	Beam.Name = "LaserBeam"
	Beam.Transparency = 1
	
	--script.Parent.Torso.Orientation = Vector3.new(script.Parent.Torso.Orientation.X,FindTarget().Orientation.Y-FindTarget().Orientation.Y*2,script.Parent.Torso.Orientation.Z)
	local Object = script.Parent.Head
	local Raycast = Ray.new(Object.CFrame.p, CFrame.new(Object.CFrame.Position, part.Position).LookVector * distance)
	local Part, Position = game.Workspace:FindPartOnRayWithIgnoreList(Raycast, {Object, Beam, script.debris}, false, true)

	local Distance = (Object.CFrame.p - Position).Magnitude
	if visibleray == true then
		Beam.Size = Vector3.new(0.1, 0.1, Distance)
		Beam.CFrame = CFrame.new(Object.CFrame.Position, part.Position) * CFrame.new(0, 0, -Distance/2)
		Beam.Transparency = 0
	else
		Beam:Destroy()
	end
	if Part ~= nil then
		if game.Players:GetPlayerFromCharacter(Part.Parent) or game.Players:GetPlayerFromCharacter(Part.Parent.Parent) then
			--script.Parent.Humanoid:MoveTo(Part.Position)
			GoTo(part.Position)
			if (part.Position - script.Parent.Head.Position).Magnitude < damagerange then
				attack()
			end
			Beam.BrickColor = BrickColor.new("Bright blue")
		else
			Beam.BrickColor = BrickColor.new("Really red")
		end	
	else
		Beam.BrickColor = BrickColor.new("White")
	end
	wait()
end

