The Best Projectile control script made by touhoo5
Key Required

The Best Projectile control script made by touhoo5

The Battle BricksTouhoosixsevenTouhoosixseven 803 views 2.5K executesUpdated Jul 7, 2026
Unrated
00
Lua Script•414 lines (13488 chars)
if getgenv().ProjectileToggle == nil then
    getgenv().ProjectileToggle = 1
end

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

local ACTIVE_PROJECTILES = {}
local IGNORED = {
    ["Rock"] = true,
    ["StoneFist"] = true,
}

local IGNORED_NPCS = {
    ["judgement"] = true,
    ["ghostwalker"] = true,
}

getgenv().RedirectMode = false
getgenv().SelectedNPC = nil
getgenv().NpcSelectorActive = false
getgenv().NpcButtons = {}

local player = Players.LocalPlayer
local mouse = player:GetMouse()

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "ProjectileToggleGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = player:WaitForChild("PlayerGui")

local container = Instance.new("Frame")
container.Name = "ButtonContainer"
container.Size = UDim2.new(0, 90, 0, 40)
container.Position = UDim2.new(0.5, -45, 0, 10)
container.BackgroundTransparency = 1
container.Parent = screenGui

local toggleButton = Instance.new("TextButton")
toggleButton.Name = "ProjectileToggleButton"
toggleButton.Size = UDim2.new(0, 40, 0, 40)
toggleButton.Position = UDim2.new(0, 0, 0, 0)
toggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
toggleButton.TextSize = 0
toggleButton.Text = ""
toggleButton.BorderSizePixel = 0
toggleButton.Parent = container

local npcSelectorButton = Instance.new("TextButton")
npcSelectorButton.Name = "NpcSelectorButton"
npcSelectorButton.Size = UDim2.new(0, 40, 0, 40)
npcSelectorButton.Position = UDim2.new(0, 50, 0, 0)
npcSelectorButton.BackgroundColor3 = Color3.fromRGB(128, 0, 128)
npcSelectorButton.TextSize = 0
npcSelectorButton.Text = ""
npcSelectorButton.BorderSizePixel = 0
npcSelectorButton.Parent = container

-- Drag logic using mouse events
local dragging = false
local didDrag = false
local dragStartX, dragStartY = 0, 0
local containerStartX, containerStartY = 0, 0
local dragThreshold = 4

local function onMouseDown()
    dragging = true
    didDrag = false
    dragStartX = mouse.X
    dragStartY = mouse.Y
    containerStartX = container.Position.X.Offset
    containerStartY = container.Position.Y.Offset
end

local function onMouseMove()
    if not dragging then return end
    local dx = mouse.X - dragStartX
    local dy = mouse.Y - dragStartY
    if math.abs(dx) > dragThreshold or math.abs(dy) > dragThreshold then
        didDrag = true
    end
    if didDrag then
        container.Position = UDim2.new(
            container.Position.X.Scale,
            containerStartX + dx,
            container.Position.Y.Scale,
            containerStartY + dy
        )
    end
end

local function onMouseUp()
    dragging = false
end

toggleButton.MouseButton1Down:Connect(onMouseDown)
npcSelectorButton.MouseButton1Down:Connect(onMouseDown)
mouse.Move:Connect(onMouseMove)
toggleButton.MouseButton1Up:Connect(onMouseUp)
npcSelectorButton.MouseButton1Up:Connect(onMouseUp)
UserInputService.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        dragging = false
    end
end)

local function getEnemyFolder()
    local folders = Workspace:FindFirstChild("NPCFolders")
    return folders and folders:FindFirstChild("EnemyFolder")
end

local function getFriendlyFolder()
    local folders = Workspace:FindFirstChild("NPCFolders")
    return folders and folders:FindFirstChild("FriendlyFolder")
end

local function getProjectileFolder()
    return Workspace:FindFirstChild("Projectile")
end

local function getRedBaseCenter()
    local folders = Workspace:FindFirstChild("NPCFolders")
    if not folders then return nil end
    local baseFolder = folders:FindFirstChild("BaseFolder")
    if not baseFolder then return nil end
    local redBase = baseFolder:FindFirstChild("Red Base")
    if not redBase then return nil end
    return redBase:GetPivot()
end

local function updateButtonColor()
    toggleButton.BackgroundColor3 = getgenv().RedirectMode
        and Color3.fromRGB(255, 255, 255)
        or Color3.fromRGB(0, 0, 0)
end

local function clearNpcButtons()
    for _, billboard in pairs(getgenv().NpcButtons) do
        if billboard then billboard:Destroy() end
    end
    getgenv().NpcButtons = {}
end

local function updateSelectorButtonColor()
    npcSelectorButton.BackgroundColor3 = getgenv().NpcSelectorActive
        and Color3.fromRGB(0, 255, 0)
        or Color3.fromRGB(128, 0, 128)
end

local function spawnNpcButtons()
    clearNpcButtons()
    local enemyFolder = getEnemyFolder()
    if not enemyFolder then return end

    for _, npc in ipairs(enemyFolder:GetChildren()) do
        if IGNORED_NPCS[npc.Name:lower()] then continue end
        local humanoid = npc:FindFirstChildOfClass("Humanoid")
        local torso = npc:FindFirstChild("Torso") or npc:FindFirstChild("UpperTorso") or npc:FindFirstChild("HumanoidRootPart")

        if humanoid and humanoid.Health > 0 and torso then
            local billboard = Instance.new("BillboardGui")
            billboard.Name = "NpcTargetButton"
            billboard.Size = UDim2.new(0, 50, 0, 50)
            billboard.StudsOffset = Vector3.new(0, 0, 0)
            billboard.AlwaysOnTop = true
            billboard.Adornee = torso
            billboard.Parent = torso

            local frame = Instance.new("Frame")
            frame.Size = UDim2.new(1, 0, 1, 0)
            frame.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
            frame.BackgroundTransparency = 0.3
            frame.BorderSizePixel = 0
            frame.Parent = billboard

            getgenv().NpcButtons[npc] = billboard
        end
    end
end

local function getNPCFromTarget(target)
    if not target then return nil end
    local enemyFolder = getEnemyFolder()
    if not enemyFolder then return nil end
    for _, npc in ipairs(enemyFolder:GetChildren()) do
        if IGNORED_NPCS[npc.Name:lower()] then continue end
        if target:IsDescendantOf(npc) then
            local humanoid = npc:FindFirstChildOfClass("Humanoid")
            if humanoid and humanoid.Health > 0 then
                return npc
            end
        end
    end
    return nil
end

local function isIgnored(name)
    if IGNORED[name] then return true end
    if name:lower() == "stonefist" then return true end
    return false
end

local function getTarnishedTrowel()
    local friendlyFolder = getFriendlyFolder()
    if not friendlyFolder then return nil end
    for _, npc in ipairs(friendlyFolder:GetChildren()) do
        if npc.Name == "Tarnished Trowel" then
            local humanoid = npc:FindFirstChildOfClass("Humanoid")
            local rootPart = npc:FindFirstChild("HumanoidRootPart")
            if humanoid and humanoid.Health > 0 and rootPart then
                return npc
            end
        end
    end
    return nil
end

local function getStrongestNPC(enemyFolder)
    local strongestNPC = nil
    local highestHealth = 0
    for _, npc in ipairs(enemyFolder:GetChildren()) do
        if IGNORED_NPCS[npc.Name:lower()] then continue end
        local humanoid = npc:FindFirstChildOfClass("Humanoid")
        local rootPart = npc:FindFirstChild("HumanoidRootPart")
        if humanoid and humanoid.Health > 0 and rootPart then
            if humanoid.Health > highestHealth then
                highestHealth = humanoid.Health
                strongestNPC = npc
            end
        end
    end
    return strongestNPC
end

local function getClosestNPC(projectile, enemyFolder)
    local closestNPC = nil
    local shortestDistance = math.huge
    for _, npc in ipairs(enemyFolder:GetChildren()) do
        if IGNORED_NPCS[npc.Name:lower()] then continue end
        local humanoid = npc:FindFirstChildOfClass("Humanoid")
        local rootPart = npc:FindFirstChild("HumanoidRootPart")
        if humanoid and humanoid.Health > 0 and rootPart then
            local distance = (rootPart.Position - projectile.Position).Magnitude
            if distance < shortestDistance then
                shortestDistance = distance
                closestNPC = npc
            end
        end
    end
    return closestNPC
end

local function hasEnemies(enemyFolder)
    for _, npc in ipairs(enemyFolder:GetChildren()) do
        if IGNORED_NPCS[npc.Name:lower()] then continue end
        local humanoid = npc:FindFirstChildOfClass("Humanoid")
        if humanoid and humanoid.Health > 0 then
            return true
        end
    end
    return false
end

local function snapTo(projectile, cf)
    projectile.CFrame = cf
    projectile.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
    projectile.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
end

local function getTeleportTarget(projectile)
    if getgenv().SelectedNPC then
        local humanoid = getgenv().SelectedNPC:FindFirstChildOfClass("Humanoid")
        local rootPart = getgenv().SelectedNPC:FindFirstChild("HumanoidRootPart")
        if humanoid and humanoid.Health > 0 and rootPart then
            return rootPart.CFrame
        else
            getgenv().SelectedNPC = nil
            getgenv().NpcSelectorActive = false
            updateSelectorButtonColor()
            clearNpcButtons()
        end
    end

    if getgenv().RedirectMode then
        local trowel = getTarnishedTrowel()
        if trowel and trowel:FindFirstChild("HumanoidRootPart") then
            return trowel.HumanoidRootPart.CFrame
        end
        return getRedBaseCenter()
    end

    local enemyFolder = getEnemyFolder()
    if not enemyFolder or not hasEnemies(enemyFolder) then
        return getRedBaseCenter()
    end

    local target
    if projectile.Name == "Spam" then
        target = getStrongestNPC(enemyFolder)
    else
        target = getClosestNPC(projectile, enemyFolder)
    end

    if target and target:FindFirstChild("HumanoidRootPart") then
        return target.HumanoidRootPart.CFrame
    end

    return getRedBaseCenter()
end

local function startTeleportLoop()
    if getgenv().TeleportLoopConn then return end
    getgenv().TeleportLoopConn = RunService.Heartbeat:Connect(function()
        local elapsed = (tick() - (getgenv().LastTeleportTime or 0))
        if elapsed < 0 then return end
        getgenv().LastTeleportTime = tick()
        for projectile in pairs(ACTIVE_PROJECTILES) do
            if projectile and projectile.Parent then
                local cf = getTeleportTarget(projectile)
                if cf then snapTo(projectile, cf) end
            else
                ACTIVE_PROJECTILES[projectile] = nil
            end
        end
    end)
end

local function cleanup()
    if getgenv().ProjConn then getgenv().ProjConn:Disconnect() getgenv().ProjConn = nil end
    if getgenv().ProjFolderConn then getgenv().ProjFolderConn:Disconnect() getgenv().ProjFolderConn = nil end
    if getgenv().TeleportLoopConn then getgenv().TeleportLoopConn:Disconnect() getgenv().TeleportLoopConn = nil end
    if getgenv().ClickConn then getgenv().ClickConn:Disconnect() getgenv().ClickConn = nil end
    table.clear(ACTIVE_PROJECTILES)
end

local function hookFolder(projFolder)
    if getgenv().ProjConn then getgenv().ProjConn:Disconnect() end
    getgenv().ProjConn = projFolder.ChildAdded:Connect(function(projectile)
        if getgenv().ProjectileToggle == 2 then return end
        if not projectile:IsA("BasePart") then return end
        if isIgnored(projectile.Name) then return end

        projectile.Size = Vector3.new(0.0001, 0.0001, 0.0001)

        local cf = getTeleportTarget(projectile)
        if cf then snapTo(projectile, cf) end

        ACTIVE_PROJECTILES[projectile] = true

        task.delay(0.05, function()
            if projectile and projectile.Parent then
                ACTIVE_PROJECTILES[projectile] = nil
                projectile:Destroy()
            end
        end)
    end)
end

toggleButton.MouseButton1Click:Connect(function()
    if didDrag then didDrag = false return end
    getgenv().RedirectMode = not getgenv().RedirectMode
    updateButtonColor()
end)

npcSelectorButton.MouseButton1Click:Connect(function()
    if didDrag then didDrag = false return end
    if getgenv().NpcSelectorActive then
        getgenv().SelectedNPC = nil
        getgenv().NpcSelectorActive = false
        clearNpcButtons()
        if getgenv().ClickConn then
            getgenv().ClickConn:Disconnect()
            getgenv().ClickConn = nil
        end
    else
        getgenv().NpcSelectorActive = true
        spawnNpcButtons()

        getgenv().ClickConn = mouse.Button1Down:Connect(function()
            if not getgenv().NpcSelectorActive then return end
            local target = mouse.Target
            local npc = getNPCFromTarget(target)
            if npc then
                getgenv().SelectedNPC = npc
                getgenv().NpcSelectorActive = false
                updateSelectorButtonColor()
                clearNpcButtons()
                if getgenv().ClickConn then
                    getgenv().ClickConn:Disconnect()
                    getgenv().ClickConn = nil
                end
            end
        end)
    end
    updateSelectorButtonColor()
end)

if getgenv().ProjectileToggle == 2 then
    cleanup()
else
    cleanup()
    startTeleportLoop()

    local projFolder = getProjectileFolder()
    if projFolder then hookFolder(projFolder) end

    getgenv().ProjFolderConn = Workspace.ChildAdded:Connect(function(child)
        if child.Name == "Projectile" then
            hookFolder(child)
        end
    end)
end

Features & Information

Ye it can control projectile target and delete enemy projectile so you can directly hit enemy base with this script and it made by my friend touhoo5 (he want credit and allow me to upload this) Also check demon_bank on YouTube for showcase and how to use!
#TheBattleBricks#TBB

Community Comments (3)

LittleapplecatLittleapplecatSep 4, 2026

I think the demon_bank delete the vid

execgaming62execgaming62Sep 4, 2026

This isn’t yours, it’s by a guy named fraud your just stealing it and reuploading it your not cool. You can’t script. Your just a little larp

Bacon_HappyTHBacon_HappyTHSep 5, 2026

This clip deletes Mortis's attacks as well. It deletes everything. There are no actual attacks, but what it deletes is the * we need to use to counterattack. How are we supposed to attack him now?

More Scripts for The Battle Bricks