The Battle Bricks Script – Friendly and Enemy Newell Script

The Battle Bricks Script – Friendly and Enemy Newell Script

The Battle Bricks 20 hours ago
8 views
The Battle Bricks Script – Friendly and Enemy Newell Script Keyless
DeltaDev
Play Game Game Link

Description

A highly customisable open-source script made in such a way to make Friendly Newell overpowered whilst completely murking Enemy Newell.

Features

  • Friendly Newell Teapot Retarget
  • Enemy Newell Useless
  • Customisable Target Options
Compatible Executors

Script

local TargetMode = 1
-- ^ This customizable config makes both Friendly and Enemy Newell's teapots teleport to a certain enemy or thing. As of right now this config has 6 options, those being: 1 = closest enemy, 2 = farthest enemy, 3 = weakest enemy, 4 = strongest enemy, 5 = random enemy, and lastly 6 = enemy base.

local PrimaryTargets = {}
-- ^ An optional list you can add enemies to for both Friendly and Enemy Newell to target, making their teapots teleport to the chosen enemy/ies. Leave ({}) blank to disable. THIS CONFIG TAKES PRIORITY OVER TARGET MODE!

local IgnoreTargets = {}
-- ^ An optional list you can add enemies to for both Friendly and Enemy Newell to ignore, making their teapots not teleport to the chosen enemy/ies. Leave ({}) blank to disable. THIS CONFIG TAKES PRIORITY OVER TARGET MODE!

-- DO NOT ADD ANYTHING IN EITHER OF THESE TWO BRACKETS BELOW, THEY ARE THERE TO CREATE SETS FOR INSTANT LOOKUPS TO PREVENT THE ENGINE FROM CRASHING. DO NOT CONFUSE THEM FOR THEIR CONFIG COUNTERPARTS.
local primarySet = {}
local ignoreSet = {}

local function updateTargetSets()
	table.clear(primarySet)
	table.clear(ignoreSet)
	for _, name in ipairs(PrimaryTargets) do primarySet[name] = true end
	for _, name in ipairs(IgnoreTargets) do ignoreSet[name] = true end
end
updateTargetSets()

local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")

local npcFolder = Workspace:WaitForChild("NPCFolders")
local enemyFolder = npcFolder:WaitForChild("EnemyFolder")
local baseFolder = npcFolder:WaitForChild("BaseFolder")

local projectileFolder = Workspace:WaitForChild("Projectile")

local pendingTeapots = {} 
local activeTeapots = {}  
local lockedToBase = {}

local bodyAngularList = {}
local bodyVelocityList = {}

local TeapotVelocity = Vector3.new(0, 0, -200)

local function removeTouchInterest(descendant)
	if descendant and descendant:IsA("TouchInterest") then
		descendant:Destroy()
	end
end

local function getTargetNPC(fromPosition)
	if TargetMode ~= 1 and TargetMode ~= 2 and TargetMode ~= 3 and TargetMode ~= 4 and TargetMode ~= 5 and TargetMode ~= 6 then
		TargetMode = 1
	end

	local validTargets = {}
	local primaryFound = false

	for _, npc in ipairs(enemyFolder:GetChildren()) do
		if ignoreSet[npc.Name] then continue end

		local humanoid = npc:FindFirstChild("Humanoid")
		local root = npc:FindFirstChild("HumanoidRootPart")

		if humanoid and humanoid.Health > 0 and root then
			local isPrimary = primarySet[npc.Name] ~= nil
			
			if isPrimary then
				if not primaryFound then
					validTargets = {}
					primaryFound = true
				end
				table.insert(validTargets, npc)
			elseif not primaryFound then
				table.insert(validTargets, npc)
			end
		end
	end

	if #validTargets == 0 then return nil end

	if TargetMode == 6 and not primaryFound then
		return nil
	end

	local selectedNPC = nil

	if TargetMode == 2 then
		local farthestDistance = -1
		for _, npc in ipairs(validTargets) do
			local distance = (npc.HumanoidRootPart.Position - fromPosition).Magnitude
			if distance > farthestDistance then
				farthestDistance = distance
				selectedNPC = npc
			end
		end
	elseif TargetMode == 3 then
		local minHealth = math.huge
		for _, npc in ipairs(validTargets) do
			local health = npc.Humanoid.Health
			if health  maxHealth then
				maxHealth = health
				selectedNPC = npc
			end
		end
	elseif TargetMode == 5 then
		selectedNPC = validTargets[math.random(#validTargets)]
	else
		local closestDistance = math.huge
		for _, npc in ipairs(validTargets) do
			local distance = (npc.HumanoidRootPart.Position - fromPosition).Magnitude
			if distance  0 then
			local teapot = table.remove(pendingTeapots, 1)
			if teapot and teapot.Parent then
				local bav = teapot:FindFirstChildOfClass("BodyAngularVelocity")
				if not bav then
					bav = Instance.new("BodyAngularVelocity")
					bav.MaxTorque = Vector3.new(1e6, 1e6, 1e6)
					bav.AngularVelocity = Vector3.new(0, 0, 0)
					bav.Parent = teapot
				end
				bodyAngularList[bav] = true

				local bv = teapot:FindFirstChildOfClass("BodyVelocity")
				if not bv then
					bv = Instance.new("BodyVelocity")
					bv.MaxForce = Vector3.new(1e6, 1e6, 1e6)
					bv.Velocity = TeapotVelocity
					bv.Parent = teapot
				end
				bodyVelocityList[bv] = true

				activeTeapots[teapot] = true
				task.wait(0.25)
			end
		else
			RunService.Heartbeat:Wait()
		end
	end
end)

for _, obj in ipairs(projectileFolder:GetChildren()) do
	if obj.Name:lower():find("teapot") then
		HandleTeapot(obj)
	end
end

projectileFolder.ChildAdded:Connect(function(child)
	if child.Name:lower():find("teapot") then
		HandleTeapot(child)
	end
end)

RunService.Heartbeat:Connect(function()
	local currentRedBase = baseFolder:FindFirstChild("Red Base")
	local currentHitbox = currentRedBase and currentRedBase:FindFirstChild("MainHitbox")

	for bav, _ in pairs(bodyAngularList) do
		if bav.Parent then
			bav.AngularVelocity = Vector3.new(0, 0, 0)
		else
			bodyAngularList[bav] = nil
		end
	end

	for bv, _ in pairs(bodyVelocityList) do
		if bv.Parent then
			bv.Velocity = TeapotVelocity
		else
			bodyVelocityList[bv] = nil
		end
	end

	for teapot, _ in pairs(activeTeapots) do
		if teapot.Parent then
			if lockedToBase[teapot] then
				if currentHitbox then
					teapot.CFrame = CFrame.new(currentHitbox.Position)
				end
			else
				local targetNPC = getTargetNPC(teapot.Position)
				if targetNPC then
					teapot.Anchored = true
					local root = targetNPC:FindFirstChild("HumanoidRootPart")
					if root then
						teapot.CFrame = CFrame.new(root.Position + Vector3.new(0, 1.5, -0.5))
					end
				else
					lockedToBase[teapot] = true
					teapot.Anchored = true
					if currentHitbox then
						teapot.CFrame = CFrame.new(currentHitbox.Position)
					end
				end
			end
		else
			activeTeapots[teapot] = nil
			lockedToBase[teapot] = nil
		end
	end
end)

Comments (0)

No comments yet. Be the first!