Friendly character getting long unnecessary range

Hello developers.

I’ve created a character which will attack enemies within range (~6) studs, the issue is that the character will get increased range unnecessarily.

while task.wait(0) do
	for _, Enemy in pairs(workspace.ExistingEntities:GetChildren()) do
		if Enemy:IsA("Model") and Enemy:HasTag("EnemyTag") then

			local npcOrientation, npcSize = Enemy:GetBoundingBox()
			local boundingBox = Instance.new("Part")
			boundingBox.CanCollide = false
			boundingBox.Size = npcSize
			boundingBox.CFrame = npcOrientation
			boundingBox.Parent = Enemy

			local raycastParams = RaycastParams.new()
			raycastParams.FilterType = Enum.RaycastFilterType.Include
			raycastParams.FilterDescendantsInstances = {workspace.Model}
			raycastParams.IgnoreWater = true

			local raycastResult = workspace:Raycast(FriendCommander.HumanoidRootPart.Position, CFrame.new(FriendCommander.HumanoidRootPart.Position, boundingBox.Position).LookVector * 6, raycastParams)
			if raycastResult then
				if DB then return end
				DB = true
				Humanoid.WalkSpeed = 0

				task.wait(0.2)
				local SwingAnim = Animator:LoadAnimation(script.Swing)
				SwingAnim:Play()

				--//Greedy explosion
				local ExplosionPart = Instance.new("Part",workspace.Debris)
				game:GetService("Debris"):AddItem(ExplosionPart,10)
				ExplosionPart.Transparency = 1
				ExplosionPart.Anchored = true
				ExplosionPart.Size = Vector3.new(10, 19, 10)
				ExplosionPart.Position = Enemy.PrimaryPart.Position
				ExplosionPart.Orientation = FriendCommander.PrimaryPart.Orientation

				local GreedyExplosion = script.GREEDYEXPLOSION:Clone()
				GreedyExplosion.Parent = ExplosionPart

				--//Shockwave
				for i=1, 50 do
					ExplosionPart.Position = ExplosionPart.Position + Vector3.new(-1, 0, 0)
					GreedyExplosion:Emit(500)
					game.ReplicatedStorage.ScreenShake:FireAllClients(10)

					local GreedyExplosion2 = Instance.new("Explosion",workspace.Debris)
					GreedyExplosion2.Position = ExplosionPart.Position
					GreedyExplosion2.BlastPressure = 0
					GreedyExplosion2.DestroyJointRadiusPercent = 0

					local Hits = {}
					GreedyExplosion2.Hit:Connect(function(OnHit)
						local Model = OnHit:FindFirstAncestorWhichIsA("Model")
						local Hum = Model and Model:FindFirstChildWhichIsA("Humanoid")
						if Hum and not Hits[Model] then
							Hits[Model] = true
							Hum:TakeDamage(350)
							task.wait(0.3)
							Hits[Model] = false
						end
					end)

					local GOTTOGREEDY = FriendCommander.Sword.Sound:Clone()
					GOTTOGREEDY.Parent = ExplosionPart
					GOTTOGREEDY:Play()
					task.wait()
				end


				task.wait(3.5)
				DB = false
				Humanoid.WalkSpeed = OriginSpeed
			end

		end
	end
end