So I'm trying to make a modified paint brush that has a size setting, and paints parts in range of the size when a part is pressed. Currently I'm using GetDescendants() and Magnitude to tell if a part is in range but it lags the game a bit. Wondering if there was any other way to do this without the lag? This is the part this concerns:
function setColor(part)
local getDescendants = workspace:GetDescendants()
if canSelectObject(part) and not db then
db = true
if brushType == "PaintBrush" then
if inGui ~= true and inPalette ~= true then
if eyeDropperImg2 ~= nil then eyeDropperImg2:Remove() end
if script.Parent.area.Value == 1 then
script.Parent.Color:FireServer(1,part,primaryColor.BackgroundColor)
else
script.Parent.Color:FireServer(1,part,primaryColor.BackgroundColor)
for i,v in pairs (getDescendants) do
if v.ClassName == "Part" and v.Locked == false or v.ClassName == "UnionOperation" and v.Locked == false then
if v ~= part then
if (part.Position - v.Position).magnitude < script.Parent.area.Value then
if (v.BrickColor ~= primaryColor.BackgroundColor) then
script.Parent.Color:FireServer(1, v, primaryColor.BackgroundColor)
end
end
end
end
end
end
end

1 comment
Thanks, it doesn't lag now.