so i’ve created a paint tool for painting a grid of studs, but the brush size system i’ve made so far is pretty inefficient.
as you can see in this video, there’s a considerably delay between when the mouse is actually clicked (the circle turns neon green) and when the parts are actually painted (obvious), which although the delay is incredibly little time, it still makes the tool feel clunky and slow regardless. i want it to feel smooth, and i know a couple games with similar paint tools that are pretty much what i want to make but they’ve figured out a solution to all the lag, so i know there has to be a better way.
these are the functions responsible for painting the parts:
local script
for _, v in workspace:GetPartsInPart(cursor, params) do
if isTargeting and v.Color == targetColor then
table.insert(partsInCursor, v)
local outline = Instance.new("SelectionBox")
outline.Parent = v
outline.LineThickness = .02
outline.Adornee = v
outline.Color3 = color
outline.Name = "Outline"
elseif not isTargeting then
table.insert(partsInCursor, v)
local outline = Instance.new("SelectionBox")
outline.Parent = v
outline.LineThickness = .02
outline.Adornee = v
outline.Color3 = color
outline.Name = "Outline"
end
end
-- later in the script
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
stopPaint = false
cursor.Material = Enum.Material.Neon
while not stopPaint do
tool.Paint:FireServer(partsInCursor, color, targetColor, isTargeting)
wait()
end
the main thing i want to potentially do is reduce the amount of events i have to fire, but i just can’t think of a way to do so.
server script:
script.Parent.Paint.OnServerEvent:Connect(function(player, paintParts, color, targetColor, isTargeting)
print(#paintParts)
if #paintParts > 0 then
for _, v in paintParts do
if v.Color == color then
return
end
print(v)
if isTargeting then
v.Color = color
end
end
end
end)
if anyone has a better solution to adding brush sizes to my paint tool, i’d like to hear it.
thanks in advance