Issue with workspace:GetPartBoundsInRadius()

I’ve been attempting to code a remake/re-imagining of the ROBLOX Paintbucket, made for an upcoming game I’m working on. These snippets of code are related to the struggle I’ve recently had about the Paintbucket highlight (when hovering over an area before painting). For some reason this Module function returns a table of parts that isn’t relevant to the area at all, rendering it to look crazy weird!!! I have a feeling it might be the resizing feature.

Fortunately, the actual Painting function does work properly! I’ve attempted to change then OverlapParams part queue limit, modify the distances, but I always come up short of the wacky outcome it is currently.

What it should look like:
Screenshot 2023-09-14 161149

What is looks like with a larger size (all wacky and out of place):
Screenshot 2023-09-14 161159

-- module function to get parts in area (used for the highlight)
function Painting:getPartsInArea(areaVector3 : Vector3, areaDistance : number, handle : BasePart, reachDis : number)
    local AreaPartsValid = false
    if areaVector3 and type(areaVector3) == "vector" and areaDistance and type(areaDistance) == "number" and handle and handle:IsA("BasePart") and reachDis and type(reachDis) == "number" then
        local AreaParts = {}
        if (areaVector3 - handle.Position).Magnitude < reachDis then
            local overlapParams =
            overlapParams.MaxParts = 1000
            local FoundAreaParts = workspace:GetPartBoundsInRadius(areaVector3, areaDistance, overlapParams)
            for _, BasePart : Instance in ipairs(FoundAreaParts) do
                if BasePart and BasePart:IsA("BasePart") then
                    if (BasePart.Position - areaVector3).Magnitude < areaDistance and BasePart.Locked == false and BasePart.Size ==, 1, 1) then
                        table.insert(AreaParts, BasePart)
                        AreaPartsValid = true
        return AreaParts, AreaPartsValid
    return nil, AreaPartsValid
-- local script function that updates the highlight when hovering areas
local function updateSelection()
    if Player and ToolEquipped then
        local PlayerMouse = Player:GetMouse()
        if PlayerMouse then
            for _, SelectionBox : SelectionBox in ipairs(CurrentSelectionBoxes) do
                if SelectionBox and SelectionBox:IsA("Highlight") then
            local Parts = Modules.Painting:getPartsInArea(PlayerMouse.Hit.Position, math.clamp(CurrentPaintSize, 1, MaxPaintAreaDistance), Handle, PaintbucketReachDistance)
            if Parts then
                for _, Part : BasePart in ipairs(Parts) do
                    if Part:IsA("BasePart") then
                        local SelectionBox ="Highlight")
                        SelectionBox.Parent = Tool
                        SelectionBox.Name = "Painting_Highlight"
                        -- make color brighter for highlight
                        local H, S, V = CurrentPaintColor.Color:ToHSV()
                        local BrightenedColor = Color3.fromHSV(H, S, V * 2)
                        SelectionBox.OutlineColor = BrightenedColor
                        SelectionBox.FillColor = BrightenedColor
                        SelectionBox.FillTransparency = 0.5
                        SelectionBox.OutlineTransparency = 0.5
                        SelectionBox.DepthMode = Enum.HighlightDepthMode.Occluded
                        SelectionBox.Adornee = Part
                        table.insert(CurrentSelectionBoxes, SelectionBox)

Studio can only display 31 highlights simultaneously. That’s your issue because you have exactly 31 highlights in your second screenshot. It is catching all the other parts, but it can’t display all the highlights.

Interesting limit. Thanks for the response, I’ll just go back to SelectionBoxes instead of Highlights.

Yup, there’s a lot of those annoyingly enough.

If you want to continue using highlights you can create a model, and then just parent the parts you want to highlight into that model, and create a highlight after. Performance wise it’ll run better too.

This for example is way more than 31 blocks


I eventually reached the solution, it’ll be temporary (maybe), but I just made MeshParts have outlines and Parts have SelectionBoxes. I will make sure to look into this too.