for i,v in pairs(game.Workspace:GetChildren()) do
		if v.ClassName == "Part" and part ~= nil then
			if (part.Position-v.Position).magnitude <=  player.PlayerGui.PaintGui.CurrentColor.Thickness.Value-1 then
				local part = v
				if canSelectObject(part) then
					  if Instance.Lock(part) then
						   part.BrickColor = colorval.Value
						   Instance.Unlock(part)
					  end
				 end
			end
		end
	end
end

I have A LOT of studs all over the map This part of code is causing me a lot of lag, any way to reduce it?