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:
What is looks like with a larger size (all wacky and out of place):
-- 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.new()
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 == Vector3.new(1, 1, 1) then
table.insert(AreaParts, BasePart)
AreaPartsValid = true
end
end
end
end
return AreaParts, AreaPartsValid
end
return nil, AreaPartsValid
end
-- 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
SelectionBox:Destroy()
end
end
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 = Instance.new("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)
end
end
end
end
end
end```